Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am stuck setting my nginx to work with custom cgi programs (using xmlrpc-c library).
I am trying with fcgiwrap/spawn-fcgi like this:

$ spawn-fcgi -f /usr/bin/fcgiwrap -s /tmp/fcgi.sock

Important section of nginx.conf file would be

location /cgi-bin/test {
        root /usr/share/nginx/html/cgi-bin/test/;
        include /etc/nginx/fastcgi.conf;

        fastcgi_pass unix:/tmp/fcgi.sock;
        fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/cgi-bin/test$fastcgi_script_name;


I've tried both soceket files and ipv4/portnumber combinations but i got error:

2013/08/22 18:52:55 [notice] 1645#0: signal process started
2013/08/22 18:52:57 [crit] 1653#0: *1 connect() to unix:/tmp/fcgi.sock failed (13:             Permission denied) 
while connecting to upstream, client:, server: localhost,request: "POST /cgi-bin/test/listaccounta HTTP/1.1", upstream: "fastcgi://unix:/tmp/fcgi.sock:", host: "localhost", referrer: "http://localhost/some_page.php"

I also get 502 Bad Gateway sometimes if I mess around with options. I've tried every combination I could google (includes modifying /etc/nginx/fastcgi.conf file) (note there are separate sections in nginx.conf for php cgi and for my test programs, php works fine)
I am stuck and don't know how to configure it, am I missing something out?

this part especially:

in nginx.conf
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/cgi-bin/test/$fastcgi_script_name; #desn't work, reports error below
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/cgi-bin/test/my_prog; #it works

Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?  

i have more than one program, how to set executable not to be fixed (like my_prog above)?


share|improve this question

It looks like nginx doesn't have permission to read/write the fastcgi socket:

2013/08/22 18:52:57 [crit] 1653#0: *1 connect() to unix:/tmp/fcgi.sock failed (13:             Permission denied)

You should make sure that the user account used to launch nginx can access the socket file created by fcgi. Are they both launched as the same user?

share|improve this answer
I suspected this as well, tried both chmod a+rwx /tmp/fcgi.sock as well as running those services as root, same error (permission denied) – kometonja Aug 22 '13 at 18:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .