nested location, proxy, alias and multiple "/" locations

sergiks nginx-forum at nginx.us
Sat Jan 18 20:58:22 UTC 2014


Ciao,

I'm setting up several isolated <a href="http://laravel.com/" title="PHP
framework">Laravel</a> apps in sub-folders of a single site. Web root folder
of Laravel is called "public", and I want to access such installation by URI
"/app1/". There are static files, maybe few custom php, and a single entry
point `/index.php`.

So I came up with a config like this:
[code]
location    ^~  /app1  {
    root    /var/www/apps.mydomain.com/Laravel_app1/public;
    rewrite ^/app1/?(.*)$   /$1  break;
    
    location ~* \.(jpg|gif|png)$ {
        try_files $uri =404;
        ...
    }
    
    location ~* !(\.(jpg|gif|png))$ {
        proxy_pass              http://127.0.0.1:8081;
        ...
    }
}
[/code]

Two questions:

1. what happens to an "alias" inside a "^~" location like "location ^~ /app1
{ ... }" – seems like $uri is not changed and "/abcdef" part remains in
place.

2. how can I write a nested default "/" location after a rewrite and a
regexp location? Got [emerg] errors when trying to write it like this:
location ^~ /app1 {
    rewrite   ^/app1/?(.*)$   /$1   break;
    location ~* \.(jpg|gif|png)$ { ...static files instructions... }
    location   /   { proxy_pass ...php files and folders go to Laravel... }
}


Serge.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,246584,246584#msg-246584



More information about the nginx mailing list