Welcome! Log In Create A New Profile

Advanced

Re: Why are my CGI scripts not executed like PHP ?

Ralph Seichter
April 07, 2018 02:16PM
On 07.04.18 16:18, Francis Daly wrote:

> This mail is a bit long, but I try to cover the points raised in your
> previous mails too.

I appreciate you taking the time. Like I said, I am new to nginx. Years
of using Apache caused me to expect certain things to happen in certain
ways, and even though I studied nginx documentation and already noted
substantial differences, I'm glad for your thorough description. One
sentence in particular got me thinking:

> Perhaps /tmp/script is not executable by the fcgiwrap user, or does
> not provide correct CGI output when run in this limited environment.

Yesterday I had verified that the CGI test script was executable for
all, ran it with "su nginx -c /path/to/test.cgi", and then basically
forgot about the script, to focus all my attention on nginx, fcgiwrap,
and the other tools in my box.

Turns out that the CGI shell script I quickly typed in Vi lacks a small
but significant detail. https://tools.ietf.org/html/rfc3875 section 6.2
states "The response comprises a message-header and a message-body,
separated by a blank line", and unfortunately I omitted that blank line.

Seeing that, the error message I included in yesterday's email makes
more sense to me: "Upstream prematurely closed FastCGI stdout while
reading response header". With the blank line absent, all returned data
was considered message-header, and when the stream was closed, no
message-body had apparently been received.

As soon as I added the missing blank line to my test.cgi, all worked
smoothly. Here's the relevant section of my nginx configuration:

server {
listen *:443 ssl;
server_name test.mydomain.tld;
# ...logging and basic SSL stuff here...

root /var/www/localhost/test;
index test.cgi;
location ~ \.cgi$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/run/fcgi-nginx-1;
}
}

Doesn't look like much, and according to Git, that's actually what I
used on my very first attempt with spawn-fcgi. I sure wish I had spotted
the script problem earlier. Face, meet palm.

-Ralph
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Why are my CGI scripts not executed like PHP ?

Ralph Seichter April 06, 2018 12:04PM

Re: Why are my CGI scripts not executed like PHP ?

Richard Stanway via nginx April 06, 2018 01:06PM

Why are my CGI scripts not executed like PHP ?

Ralph Seichter April 06, 2018 01:28PM

Re: Why are my CGI scripts not executed like PHP ?

Ralph Seichter April 06, 2018 03:56PM

Re: Why are my CGI scripts not executed like PHP ?

Francis Daly April 07, 2018 10:20AM

Re: Why are my CGI scripts not executed like PHP ?

Ralph Seichter April 07, 2018 02:16PM

Re: Why are my CGI scripts not executed like PHP ?

Francis Daly April 09, 2018 04:48AM

Re: Why are my CGI scripts not executed like PHP ?

Aleksandar Lazic April 10, 2018 04:56PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 181
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready