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

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


I'm setting up several isolated <a href="" 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:
location    ^~  /app1  {
    root    /var/www/;
    rewrite ^/app1/?(.*)$   /$1  break;
    location ~* \.(jpg|gif|png)$ {
        try_files $uri =404;
    location ~* !(\.(jpg|gif|png))$ {
        proxy_pass    ;

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

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


Posted at Nginx Forum:,246584,246584#msg-246584

More information about the nginx mailing list