nginx behind a forward proxy

Eran Kornblau eran.kornblau at kaltura.com
Sun Mar 12 11:21:02 UTC 2017


Hi all,

In one of our deployments, we need to set up an nginx server behind a forward proxy.
We need to have nginx issue the upstream requests using absolute URLs, e.g.:
GET http://domain/uri HTTP/1.1

We tried to use a configuration that looks like:
location ~ ^/proxy/(.*) {
        proxy_pass $scheme://proxy-ip:proxy-port/$scheme://$1$is_args$args;
}

But the problem is that there's no way to prevent the upstream request uri from starting with /
(we get /http://domain/uri instead of http://domain/uri)

I would like to submit a patch to support this flow, two options I can think of:

1.       Add a new parameter proxy_uri that will accept nginx variables, and will take priority
over the existing logic for determining the uri

2.       Add a dedicated flag for stripping the /, e.g. proxy_strip_uri_slash on/off

Pros/cons as I see it - #1 seems quite flexible and may enable additional use cases that I can't
think of right now. The cons of #1 is that there is some duplication between this directive and
proxy_pass (it enables the user to set both, but only one will apply)

Please let me whether this change makes sense, and which option you think is better

Thank you!

Eran

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20170312/fbc28555/attachment.html>


More information about the nginx-devel mailing list