Hello everyone.
I'm having troubles of setting cgi/perl support for Nginx, on OpenBSD 5.3.
I get "502 Bad Gateway" on the browser when I type /cgi-bin/test.cgi -
which is a simple "Hello World" cgi file, doesn't work with my setup.
The error.log says:
[error] 29912#0: *6 upstream prematurely closed FastCGI stdout while
reading response header from upstream,
server: localhost, request: "GET /cgi-bin/test.cgi HTTP/1.1",
upstream: "fastcgi://unix:/run/slowcgi.sock:"
# pwd
/var/www/htdocs/cgi-bin
# cat test.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html><body>Hello, world.</body></html>";
both cgi-bin folder and test.cgi file has appropriate chmod sets for
executing.
Slowcgi is running (I follow 5.3-stable branch,
but I downloaded "Makefile", "slowcgi.8" and "slowcgi.c" files and compiled
it) :
www 20010 0.0 0.1 636 1104 ?? Is 8:58PM 0:01.11 ./slowcgi
the socket is also there:
# ls -al /var/www/run/slowcgi.sock
srw-rw---- 1 www www 0 Jul 8 20:58 /var/www/run/slowcgi.sock
Thinking of chroot(), I have even tried adding a copy of perl binary to:
# ls -l /var/www/usr/bin/
-rwxr-xr-x 1 root daemon 10725 Jul 9 19:15 perl
And my nginx.conf:
server {
listen 192.168.1.4:80;
server_name localhost local.web.ns;
root /var/www/htdocs;
location ~ ^/cgi-bin/.*\.cgi$ {
root /var/www/htdocs;
gzip off;
fastcgi_pass unix:/run/slowcgi.sock;
fastcgi_index index.cgi;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}
}
}
What would be the problem that I don't get the right output on the browser
with Nginx from any .cgi files?
Thanks.