# Having troubles understanding basic location directives

**URL:** <https://www.ruby-forum.com/t/having-troubles-understanding-basic-location-directives/195064>\
**Category:** NGINX\
**Created:** [September 16, 2010, 7:02am UTC](https://www.ruby-forum.com/t/having-troubles-understanding-basic-location-directives/195064 "2010-09-16T07:02:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@thomas](https://www.ruby-forum.com/u/thomas)\
**Post date:** [September 16, 2010, 7:02am UTC](https://www.ruby-forum.com/t/having-troubles-understanding-basic-location-directives/195064/1 "2010-09-16T07:02:59Z")

</div>

So I’ve got a couple of requirements. If the file is a resource (image,  
stylesheet, etc…) then just serve it.

Pretty much everything else should be directed through my index.php file

If the domain has sqlbuddy at the beginning, just use it like normal.  
(So if they’re going to [example.com/sqlbuddy](http://example.com/sqlbuddy), then it should just run  
that without sending it through the special index.php

Also, resources for the sqlbuddy app should be served from the sqlbuddy  
root. (Sqlbuddy is just a phpmyadmin substitute)

So the resources seem to be served correctly (I’m downloading images in  
my browser correctly). Traffic also is routed through my index.php file.  
The problem is getting sqlbuddy to work. I’m just getting a 404 error.  
Ideas?

This is what I have so far:

server {

listen 80; ## listen for ipv4  
listen [::]:80 default ipv6only=on; ## listen for ipv6

server\_name \_;

location ^~ /sqlbuddy/ {  
root /var/www/example.com/public/sqlbuddy/;  
index index.php;  
}

location ~\*  
^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$  
{  
keepalive\_timeout 5 5;  
gzip on;  
gzip\_proxied expired no-cache no-store private auth;  
gzip\_types text/plain application/xml  
application/x-javascript;  
root /var/www/example.com/public/;  
access\_log off;  
expires 1s;  
}

location / {  
root /var/www/example.com/public/;  
rewrite ^(.\*) /index.php?$1 last;  
}

location ~ .php$ {  
fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_index index.php;  
include fastcgi\_params;  
fastcgi\_param SCRIPT\_FILENAME  
/var/www/example.com/public/index.php;  
}  
}

---

<div class="post-metadata">

**Author:** ![thomas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e36b37/32.png) [@thomas](https://www.ruby-forum.com/u/thomas)\
**Post date:** [September 16, 2010, 8:28am UTC](https://www.ruby-forum.com/t/having-troubles-understanding-basic-location-directives/195064/2 "2010-09-16T08:28:35Z")

</div>

On Thu, Sep 16, 2010 at 07:02:59AM +0200, Thomas Delonge wrote:

> root. (Sqlbuddy is just a phpmyadmin substitute)
> 
> location ~\*  
> }  
> fastcgi\_param SCRIPT\_FILENAME  
> /var/www/example.com/public/index.php;  
> }  
> }

server {  
listen 80; ## listen for ipv4  
listen [::]:80 default ipv6only=on; ## listen for ipv6

```
keepalive_timeout 5 5;

gzip on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml 

```

application/x-javascript;

```
root /var/www/example.com/public/;

location / {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME 

```

/var/www/example.com/public/index.php;  
}

```
location ~* 

```

^/sqlbuddy/.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$  
{  
access\_log off;  
expires 1s;  
}

```
location ~ ^/sqlbuddy/ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME
                  /var/www/example.com/public/$fastscgi_script;
}

location ~* 

```

.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$  
{  
access\_log off;  
expires 1s;  
}  
}

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
