passing data to CGI scripts via PATH_INFO
Valentin V. Bartenev
vbart at nginx.com
Thu May 22 21:52:45 UTC 2014
On Thursday 22 May 2014 22:14:23 Lyle wrote:
> On 22/05/2014 19:32, Valentin V. Bartenev wrote:
> > On Thursday 22 May 2014 16:26:54 Phil Knight wrote:
> >> Hi
> >>
> >> We are having an issue passing data to CGI scripts via PATH_INFO
> >> environment variable.
> >>
> >> for example:-
> >>
> >> http://domain.com/cgi-bin/script.cgi/=
> >>
> >> On various apache servers this works fine and the PATH_INFO variable
> >> will contain "/=", on our nginx server we are getting a 403 forbidden
> >> error. We are using fcgiwrap [1] for running CGI and .cgi scripts are
> >> executing.
> >>
> >> Could this be an issue with nginx configuration?
> > [..]
> >
> > Most likely this is an issue with the configuration.
>
> I think the relevant part is here:
>
> location /cgi-bin/ {
> root /users/folder;
> gzip off;
> fastcgi_pass unix:/var/run/fcgiwrap.socket;
> 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 SCRIPT_NAME $fastcgi_script_name;
> fastcgi_param PATH_INFO $fastcgi_path_info;
> fastcgi_param REQUEST_URI $request_uri;
> fastcgi_param DOCUMENT_URI $document_uri;
> fastcgi_param SERVER_PROTOCOL $server_protocol;
> fastcgi_param GATEWAY_INTERFACE CGI/1.1;
> fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
> 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;
>
> fastcgi_param DOCUMENT_ROOT /users/folder/cgi-bin/;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> fastcgi_connect_timeout 120;
> fastcgi_send_timeout 120;
> fastcgi_read_timeout 120;
> }
>
> I could be wrong. Any pointers would be very much appreciated.
>
> I've noticed that:
>
> http://domain.com/cgi-bin/no_existent_script.cgi
>
> Also gives a 403. So I suspect that nginx is looking for a file called =
> in a folder named api.cgi/
> I'm not sure what configuration we need to do to fix this.
[..]
As I already said, nginx knows nothing about CGI. It doesn't look for any
files in your location with "fastcgi_pass". It just passes request and
all the FastCGI params that you have configured with the values that you
have set.
For example, since you have:
fastcgi_param PATH_INFO $fastcgi_path_info;
and missing the fastcgi_split_path_info directive, then probably nginx pases
empty string in PATH_INFO.
Please, check the docs to figure out how exactly the $fastcgi_path_info
variable works and what values it takes:
http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#var_fastcgi_path_info
The whole list of variables with links to descriptions can be found here:
http://nginx.org/en/docs/varindex.html
Then, probably, you need to check fcgiwrap documentation to figure out what
variables it expects and how they are processed.
wbr, Valentin V. Bartenev
More information about the nginx
mailing list