Is it possible to configure nginx to query a service (not DNS) to determine the proxy_pass destination based on the currently-requested URI?
For example:
- Client requests http://somesite.tld/somepage, which needs to be proxied.
- nginx connects to the resolving service and sends the request URI which is used to determine the proxy destination.
- The resolving service responds, providing the hostname of the destination.
- The client’s request is redirected to the given destination.
If this is not supported, what would be a good way to do this? I could proxy_pass to a resolver+proxy, but would prefer to let nginx handle the proxying directly to the destination. Note that the resolver needs to be queried because the destinations for each URI may change.
Thanks 🙂
I don’t see a way to achieve what you are asking.
However if you are simply looking to map request args to hostnames (and they don’t change a lot), then you could probably use Nginx’s map module.
You might also be able to do something using mod_lua, but it would likely be terribly hackish.