Using map and proxy_pass

Markus Jelsma markus.jelsma at openindex.io
Fri Apr 29 19:45:51 MSD 2011


Hi list,

I'm pulling my hair out. I need to pass to different proxies based on the 
first uri segment but don't seem be able to get it working.

I have the following map:

map $uri $upstream
{
  /abc/bla/ host01;
  /xyz/bla/ host02;
}

Originally i tried using regex in the uri because different 2nd segments can 
be used, doing /abx/(.*)/ doesn't work either, or i'm using it the wrong way. 
So for now i'm trying with fixed uri's.

In the location handling the 2nd segment i rewrite and proxy_pass.

location ~ "/(.*)/abc"
{
  rewrite ^(.*)$ /another_segment$1 break;
  proxy_pass http://$upstream:8080;
}


Cheers,



More information about the nginx mailing list