Welcome! Log In Create A New Profile

Advanced

nginx behind a forward proxy

March 12, 2017 07:22AM
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

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

nginx behind a forward proxy

erankor 1104 March 12, 2017 07:22AM

Re: nginx behind a forward proxy

Francis Daly 515 March 17, 2017 11:12AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 175
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