Having troubles understanding basic location directives.

Igor Sysoev igor at sysoev.ru
Thu Sep 16 10:27:46 MSD 2010


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

> 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, 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;
>   }
> }

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 Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list