1

I have a website on ipage and works fine. I am trying to migrate it to Google Cloud and the cgi-bin is duplicated when called by a form action as shown below:

http://34.28.183.10/cgi-bin/cgi-bin/list_directory_1.cgi?directory=%2CBrasil%2CMinas+Gerais&submit_trailing_directory=

It works if I remove the extra cgi-bin such as:

http://34.28.183.10/cgi-bin/list_directory_1.cgi?directory=%2CBrasil%2CMinas+Gerais&submit_trailing_directory=

I placed the script list_directory_1.cgi in /usr/lib/cgi-bin and the form whose action calls this script looks like this:

print qq(<form action="cgi-bin/list_directory_1.cgi" method="GET">\n);

The apache2 log files shows this:

[Thu Mar 16 14:39:49.939253 2023] [cgid:error] [pid 5389:tid 140165141997312] [client 107.217.8.189:52312] AH01264: script not found or unable to stat: /usr/lib/cgi-bin/cgi-bin, referer: http://34.28.183.10/cgi-bin/list_directory_1.cgi?directory=%2CBrasil&submit_directory=

brian d foy
  • 129,424
  • 31
  • 207
  • 592

1 Answers1

3

A URL that starts with a relative path (like cgi-bin/list_directory_1.cgi) is resolved by:

  1. Taking the base URL (http://34.28.183.10/cgi-bin/list_directory_1.cgi?directory=%2CBrasil&submit_directory=)
  2. Removing everything after the last / in the path (http://34.28.183.10/cgi-bin/)
  3. Appending the relative path (http://34.28.183.10/cgi-bin/cgi-bin/list_directory_1.cgi)

Use an absolute path (starting with a single /) instead:

<form action="/cgi-bin/list_directory_1.cgi"

These are resolved by:

  1. Taking the base URL (http://34.28.183.10/cgi-bin/list_directory_1.cgi?directory=%2CBrasil&submit_directory=)
  2. Removing everything after and including the whole path (http://34.28.183.10)
  3. Appending the absolute path (http://34.28.183.10/cgi-bin/list_directory_1.cgi)
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • 1
    @MarcosCamargo – The relationship between the URL path and the filesystem path is not relevant to this problem. – Quentin Mar 16 '23 at 15:11
  • I have the same form specified in the index.html and it works the first time it is called but it doesn't work after that. – Marcos Camargo Mar 16 '23 at 15:21
  • 1
    @MarcosCamargo — I am not surprised. This answer explains why and also how to fix it. – Quentin Mar 16 '23 at 15:21