You are not logged in.

#1 2013-08-22 21:45:54

kometonja
Member
Registered: 2012-12-28
Posts: 10

nginx + cgi

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? 
Thanks

Offline

#2 2013-08-22 23:06:23

Morrad
Member
From: Washington State, USA
Registered: 2012-01-18
Posts: 54
Website

Re: nginx + cgi

What user owns the socket in /tmp/fcgi.sock?  What permissions does the socket have?

Last edited by Morrad (2013-08-22 23:06:37)


To the optimist, the glass is half full.
To the pessimist, the glass if half empty.
To the engineer, the glass is twice as big as it needs to be.

Offline

#3 2013-08-22 23:18:14

kometonja
Member
Registered: 2012-12-28
Posts: 10

Re: nginx + cgi

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) .
Also, when i tried using tcp sockets got an error:

2013/08/23 01:16:01 [notice] 6433#0: signal process started
2013/08/23 01:16:04 [error] 6448#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "POST /cgi-bin/test/testprog HTTP/1.1", upstream: "fastcgi://127.0.0.1:8000", host: "localhost", referrer: "http://localhost/script.php"

so i think problem is somewhere else..

Last edited by kometonja (2013-08-22 23:19:19)

Offline

#4 2013-08-23 13:59:44

kometonja
Member
Registered: 2012-12-28
Posts: 10

Re: nginx + cgi

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)?

Offline

Board footer

Powered by FluxBB