Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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   127.0.0.1:8000;
        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: 127.0.0.1, 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)?

Thanks

share|improve this question

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.