fastcgi_index - am I missing something obvious?

Sandra Snan sandra.snan at
Wed Oct 15 11:17:49 UTC 2014

So I have the same setup on two different servers, using fcgiwrap to
serve some basic classic style cgi scripts.

On both,
http://serverdomain.whatever/cgi-bin/index.cgi works great
and other explicit .cgi urls work.
But only on one of them, http://serverdomain.whatever/cgi-bin/ takes me
to the index.cgi. On the other I get a 502.
What am I missing?
I think the unix permissions of /usr/lib, /usr/lib/cgi-bin and its
contents, and /var/www are the same on both servers.

The error log is

2014/10/15 11:16:40 [error] 30892#0: *845 upstream prematurely closed
FastCGI stdout while reading response header from upstream, client: [my
client ip], server: [my server adress], request: "GET /cgi-bin/
HTTP/1.1", upstream: "fastcgi://unix:/var/run/fcgiwrap.socket:", host:
"[my server adress]"

Here is the conf:

server {
	listen   80;

	root /var/www/; # not really relevant
	index index.html;

	server_name my_server_name_went_here;

	location / {
		try_files $uri $uri/ /index.html;

 # this, as the rest of the conf, is the same on both

	location /cgi-bin/ {
        	gzip           off;
                # the cgi-bin directory is in /usr/lib
        	root           /usr/lib;
        	fastcgi_pass   unix:/var/run/fcgiwrap.socket;
		include /etc/nginx/fastcgi_params;
                # this next line seems to work on one, not the other
		fastcgi_index index.cgi;
		fastcgi_param SCRIPT_FILENAME  /usr/lib$fastcgi_script_name;

More information about the nginx mailing list