nginx location fine routing multiple backend

nenad nginx-forum at nginx.us
Thu Feb 20 09:47:41 UTC 2014


I neet to route requests to multiple backends, and I'm can't match all, what
I have so far:

...
root /srv/www;

== below does what it should ==
location ~
/assets/(.+\.(?:gif|jpe?g|png|txt|html|css|eot|svg|ttf|woff|swf|js))$ {
        alias /srv/www2/$1;

 }

==> below should match only: /, /en, /en/, /de, /de/ but NOT: /search/,
/search this should be catched by last location
location ~ /$ {
        alias /srv/www3;
        ...
        try_files $uri $uri/ /index.php$is_args$args;
       location ~* {
          ...
       }
}

==> should match: /about, /en/about, /about/, /en/about/ ... same alias as
above probably this can mbe merged 
location ~ (about|terms|privacy) {
        alias /srv/www3;
}

==> below should match all other and send to php-fpm, I had must remove
location / as nginx don't accept because ovveride

index index.php;
 try_files $uri $uri/ @handler; 

 location @handler {
        rewrite ^/(.*)$ /index.php/$1;
 }    
    
 location ~ \.php {
    ...
}

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



More information about the nginx mailing list