upstream and proxy_pass behavior

Philip Walenta philip.walenta at gmail.com
Fri Sep 23 16:38:44 UTC 2016


I'm trying to reduce the number of location blocks I need for an
application by trying to route using a query parameter.

My URL looks like this: https://www.example.com/api/v1/proxy/?tid=9999

If I do this in my location block:
location ~* /api/v1/proxy {
                 proxy_pass http://origin.$arg_tid:10001;
}

and have an upstream of:

upstream origin.9999 {
                 server 1.2.3.4;
}

I see an error of:

*51 no resolver defined to resolve origin.9999, client: 5.6.7.8, server:
www.example.com, request: "GET /api/v1/proxy/?tid=9999 HTTP/1.1", host: "
www.example.com" - as if it only considers a DNS lookup, even though there
is an upstream server block configured.

However, if I change my location block (removing the port):
location ~* /api/v1/proxy {
                 proxy_pass http://origin.$arg_tid;
}

and have an upstream of:

upstream origin.9999 {
                 server 1.2.3.4:10001;
}

It works perfectly.


Is there a reason the first example isn't working?

It's very valuable to me to be able to pass the port to the upstream server
as shown in the second example as it reduces the number of upstream blocks
I need by a factor of 10 or more.

Thanks in advance for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160923/b511b6ac/attachment.html>


More information about the nginx mailing list