alias + fastcgi

António P. P. Almeida appa at perusio.net
Mon Jul 18 02:29:43 UTC 2011


On 18 Jul 2011 02h16 WEST, nginx-forum at nginx.us wrote:

> 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".

Try:

  location ~* /cgi-bin/(?<script>.+\.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




More information about the nginx mailing list