Welcome! Log In Create A New Profile

Advanced

upstream and proxy_pass behavior

Philip Walenta
September 23, 2016 12:40PM
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.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

upstream and proxy_pass behavior

Philip Walenta September 23, 2016 12:40PM

Re: upstream and proxy_pass behavior

Maxim Dounin September 23, 2016 03:00PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready