passing data to CGI scripts via PATH_INFO

Lyle webmaster at
Fri May 23 09:17:50 UTC 2014

On 22/05/2014 22:52, Valentin V. Bartenev wrote:
> On Thursday 22 May 2014 22:14:23 Lyle wrote:
>> ...
>> 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:

Ah, I see. It's the FastCGI module that's reading the wrong filename.

I think I understand the process now. Nginx is passing variables to the 
fastcgi module, as defined in the config. One of these being:
fastcgi_param       SCRIPT_FILENAME $document_root$fastcgi_script_name;
$fastcgi_script_name being everything after http://.../ by default. So 
FastCGI was trying to open a  file that didn't exist. The 
fastcgi_split_path_info variable addresses this issue, by overloading 
$fastcgi_script_name and $fastcgi_path_info with the split from the 
regexp. So adding the following:

fastcgi_split_path_info       ^(.+\.(?:cgi|pl))(.*)$;

Before the fastcgi_param instructions has fixed the issue. Hooray!

Thanks for your help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list