Skip to content
Advertisement

Need help on Nginx CGI Configuration

I need to set the nginx configurations such that the URL “http://host/cgi-bin/hw.sh/some/path/to/data/” should trigger the shell script “hw.sh” present under path “/usr/lib/cgi-bin/“.

Now, according to the instructions mentioned in page https://www.howtoforge.com/serving-cgi-scripts-with-nginx-on-debian-squeeze-ubuntu-11.04-p3, we need to set the configurations under a “.vhost” file. But I have a default file already present under path “/etc/nginx/sites-available/default” instead of a .vhost file.

And when I use the same configurations, I get HTTP/1.1 403 Forbidden error. I have made sure that the script has required executable rights too. Below is the error received in nginx logs.

JavaScript

I need help in writing the correct configuration so that my URL above executes the hw.sh script under the path mentioned above and returns proper output. Could someone please help me out here?

Below is my configuration used under default file.

JavaScript

Advertisement

Answer

Line “fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;” in the configuration was causing the problem. When i changed it to “fastcgi_param SCRIPT_FILENAME $request_filename;”, everything is working as expected.

Advertisement