Using aliases with fast cgi results in… strange results.
With this config:
location /cgi-bin/ {
alias /home/nagios/nagios/sbin;
include /etc/nginx/fastcgi.conf;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
, if you request /cgi-bin/test.cgi, $document_root is changed to
/home/nagios/nagios/sbin, as you would expect. However,
$fastcgi_script_name remains /cgi-bin/test.cgi. Shouldn’t
$fastcgi_script_name and $uri be changed to reflect that fact that this
is operating inside the alias? I would think $fastcgi_script_name and
$uri would both be /test.cgi, and not include the “/cgi-bin”.
Posted at Nginx Forum:
On Mon, Jul 18, 2011 at 8:16 AM, sonicsnes [email protected] wrote:
Using aliases with fast cgi results in… strange results.
yes you will. And you will also waste several hours trying to solve it.
(personal tips: forget alias, use symlink instead)
You sir, are brilliant. I’ve done this before, and completely,
completely forgot about it. However, perhaps this “bug” should be fixed
eventually
Posted at Nginx Forum:
On 18 Jul 2011 02h16 WEST, [email protected] wrote:
, if you request /cgi-bin/test.cgi, $document_root is changed to
/home/nagios/nagios/sbin, as you would expect. However,
$fastcgi_script_name remains /cgi-bin/test.cgi. Shouldn’t
$fastcgi_script_name and $uri be changed to reflect that fact that
this is operating inside the alias? I would think
$fastcgi_script_name and $uri would both be /test.cgi, and not
include the “/cgi-bin”.
Try:
location ~* /cgi-bin/(?.+.cgi)$ {
root /home/nagios/nagios/sbin;
include /etc/nginx/fastcgi.conf;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
— appa