proxy pass

Igor Sysoev is at rambler-co.ru
Thu Nov 29 22:06:21 MSK 2007


On Thu, Nov 29, 2007 at 10:49:09AM -0800, Cliff Wells wrote:

> On Thu, 2007-11-29 at 09:22 +0300, Igor Sysoev wrote:
> > On Wed, Nov 28, 2007 at 04:55:25PM -0800, Eire Angel wrote:
> 
> > The proxy_pass supports variables, for example:
> > 
> >      proxy_pass  http://$host$uri;
> > 
> > and the the host part will be resolved on the fly.
> 
> 
> Upgraded to Nginx 0.6.20.
> 
> 
> I tried once again to use:
> 
> http {
>     map $host $backend {
>         hostnames;
>         .cellarstella.com 127.0.0.6:8000;
>     }
> 
> 
>     server {
>         server_name cellarstella.com www.cellarstella.com;
> 
>         location / {
>                 # proxy_pass http://127.0.0.6:8000; # this works
>                 proxy_pass http://$backend;
>                 include /etc/nginx/proxy.conf;
>         }
>     }
> 
> }
> 
> 
> But I get this in the error log:
> 
> 
> 2007/11/29 10:35:52 [error] 2698#0: *28 no resolver defined to resolve 127.0.0.6, client: 67.189.89.59, server: www.cellarstella.com, request: "GET / HTTP/1.1", host: "www.cellarstella.com"
> 
> 
> Is "map" not yet supported for proxy_pass or am I just doing it wrong?

First, you need add URI-part:

-              proxy_pass http://$backend;
+              proxy_pass http://$backend$request_uri;

Second, after proxy_pass has parsed string it tries to resolve a host in
following order:

1) search all described upstreams,
2) try external resolver (named/bind/etc); you should define it
   in http, server, or location section:

       resolver 127.0.0.1;

   however, if the host is an ip address, then nginx does not send DNS
   query to the resolver, but use the ip address.


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list