I'm running Debian 6.0.3
(squeeze
), nginx-0.7.67
, fcgiwrap-1.0-1+squeeze1
. Here is the test script:
#!/usr/bin/perl
use 5.010;
use warnings;
use strict;
use Data::Dumper;
print "Content-Type: text/html\n\n";
say Dumper {map {$_ => $ENV{$_}} 'SCRIPT_NAME', 'DOCUMENT_ROOT', 'WHATEVER'};
say "$<, $>, $(, $)";
And here's the nginx
configuration:
server {
server_name domain.com;
root /home/yuri/6;
access_log /var/log/nginx/domain.com-access.log;
error_log /var/log/nginx/domain.com-error.log;
location /cgi-bin/ {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param DOCUMENT_ROOT /home/yuri/7/;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param WHATEVER 1;
fastcgi_param WHATEVER 2;
}
location /1.php {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param PHP_ADMIN_VALUE cgi.fix_pathinfo=1;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME whatever;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Here's what I get in browser if going to url http://domain.com/cgi-bin/1.pl:
$VAR1 = { 'SCRIPT_NAME' => '/cgi-bin/1.pl', 'DOCUMENT_ROOT' => '/home/yuri/7/', 'WHATEVER' => '2' };
So it seems, that fcgiwrap
uses the first DOCUMENT_ROOT
for looking up for the script, but the script gets the last values of params. If you change the order of DOCUMENT_ROOT
directives, web server returns 403
. The question is... how come?
php
though works as expected: the second SCRIPT_FILENAME
overrides the first one.
fastcgi_params
and then override default values. Also/home/yuri/7/1.pl
was meant to be non-existent.getenv
optimization... I think it was like "Why bother?" And... thanks for your answer :)