# Alias + fastcgi

**URL:** <https://www.ruby-forum.com/t/alias-fastcgi/209578>\
**Category:** NGINX\
**Created:** [July 18, 2011, 3:16am UTC](https://www.ruby-forum.com/t/alias-fastcgi/209578 "2011-07-18T03:16:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [July 18, 2011, 3:16am UTC](https://www.ruby-forum.com/t/alias-fastcgi/209578/1 "2011-07-18T03:16:53Z")

</div>

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:

> **[alias + fastcgi](https://forum.nginx.org/read.php?2,212501,212501#msg-212501)**
>
> 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/fc

---

<div class="post-metadata">

**Author:** ![sonicsnes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sonicsnes](https://www.ruby-forum.com/u/sonicsnes)\
**Post date:** [July 18, 2011, 3:20am UTC](https://www.ruby-forum.com/t/alias-fastcgi/209578/2 "2011-07-18T03:20:37Z")

</div>

On Mon, Jul 18, 2011 at 8:16 AM, sonicsnes [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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)

---

<div class="post-metadata">

**Author:** ![sonicsnes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sonicsnes](https://www.ruby-forum.com/u/sonicsnes)\
**Post date:** [July 18, 2011, 3:22am UTC](https://www.ruby-forum.com/t/alias-fastcgi/209578/3 "2011-07-18T03:22:29Z")

</div>

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:

> **[Re: alias + fastcgi](https://forum.nginx.org/read.php?2,212501,212503#msg-212503)**
>
> 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/fc

---

<div class="post-metadata">

**Author:** ![sonicsnes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sonicsnes](https://www.ruby-forum.com/u/sonicsnes)\
**Post date:** [July 18, 2011, 4:30am UTC](https://www.ruby-forum.com/t/alias-fastcgi/209578/4 "2011-07-18T04:30:24Z")

</div>

On 18 Jul 2011 02h16 WEST, [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
