Using map and proxy_pass

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


Accidentally sent it too early. See below

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

I've tried various approaches such as using $upstream in rewrite or other 
combinations but they always result in a HTTP 500 error:

2011/04/29 15:50:44 [error] 17886#0: *2 invalid host in upstream ":8080",

etc.

Is there anyone that can point me in the right direction?

> 
> 
> Cheers,
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx




More information about the nginx mailing list