Why are my CGI scripts not executed like PHP ?

Ralph Seichter m16+nginx at monksofcool.net
Fri Apr 6 19:53:27 UTC 2018


On 06.04.18 19:04, Richard Stanway wrote:

> https://www.nginx.com/resources/wiki/start/topics/examples/fcgiwrap/

I altered my setup to use fcgiwrap. Since then, I keep getting "502 Bad
Gateway" errors, with log entries like this:

  2018/04/06 21:21:02 [error] 17838#0: *1 upstream prematurely closed
  FastCGI stdout while reading response header from upstream, client:
  123.234.123.234, server: test.mydomain.tld, request: "GET / HTTP/1.1",
  upstream: "fastcgi://unix:/tmp/cgi.sock:", host: "test.mydomain.tld:8443"

I use fcgiwrap 1.1.0 from 2013, which appears to be the latest available
release according to https://github.com/gnosek/fcgiwrap . I tried both
the Perl script at the location you linked and spawn-fcgi 1.6.4 as an
alternative, but the 502 error pops up regardlesss. Permissions for the
socket are as follows:

  $ ls -l /tmp/cgi.sock
  srwx------ 1 nginx nginx 0 Apr  6 21:48 /tmp/cgi.sock=

Interestingly I found this old message of Richard's:

  http://mailman.nginx.org/pipermail/nginx/2014-January/041963.html

Unfortunately no amount of meddling with SCRIPT_FILENAME, including
setting the absolute path to the CGI script, made any difference for me.

I don't know how to debug this further. Development of fcgiwrap seems to
have ended years ago and the project page is no longer connected. I'd be
grateful for more ideas how to solve this puzzle.

-Ralph



More information about the nginx mailing list