From 3f650bbd11aec838324189b4510b13318e536a61 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 21 Aug 2017 17:54:02 +0200 Subject: [PATCH] Support X-Forwarded-Port. --- glide.lock | 6 +++--- glide.yaml | 2 +- vendor/github.com/vulcand/oxy/forward/headers.go | 1 + vendor/github.com/vulcand/oxy/forward/rewrite.go | 6 ++++++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/glide.lock b/glide.lock index 620f37b5e..5e16e0e85 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: b056b388f961ddc3509b19b4546d8dfc70fd50ebd1ca47f2fd2de67bf49ba01e -updated: 2017-08-12T14:15:06.346751095+02:00 +hash: b970da88f72aebed9ac07a31db3f40045de0cd63190a2aae8ce18b55ec3f434a +updated: 2017-08-21T14:15:06.346751095+02:00 imports: - name: cloud.google.com/go version: 2e6a95edb1071d750f6d7db777bf66cd2997af6c @@ -477,7 +477,7 @@ imports: - name: github.com/urfave/negroni version: 490e6a555d47ca891a89a150d0c1ef3922dfffe9 - name: github.com/vulcand/oxy - version: d40fb60c9a1620892a6fc146dcdc891fb02bd488 + version: 3772a8e4408fb033d00a947d340475e116854b1a repo: https://github.com/containous/oxy.git vcs: git subpackages: diff --git a/glide.yaml b/glide.yaml index 346ec3e72..2023623f8 100644 --- a/glide.yaml +++ b/glide.yaml @@ -12,7 +12,7 @@ import: - package: github.com/cenk/backoff - package: github.com/containous/flaeg - package: github.com/vulcand/oxy - version: d40fb60c9a1620892a6fc146dcdc891fb02bd488 + version: 3772a8e4408fb033d00a947d340475e116854b1a repo: https://github.com/containous/oxy.git vcs: git subpackages: diff --git a/vendor/github.com/vulcand/oxy/forward/headers.go b/vendor/github.com/vulcand/oxy/forward/headers.go index 6c10497af..d5d38bfd8 100644 --- a/vendor/github.com/vulcand/oxy/forward/headers.go +++ b/vendor/github.com/vulcand/oxy/forward/headers.go @@ -4,6 +4,7 @@ const ( XForwardedProto = "X-Forwarded-Proto" XForwardedFor = "X-Forwarded-For" XForwardedHost = "X-Forwarded-Host" + XForwardedPort = "X-Forwarded-Port" XForwardedServer = "X-Forwarded-Server" Connection = "Connection" KeepAlive = "Keep-Alive" diff --git a/vendor/github.com/vulcand/oxy/forward/rewrite.go b/vendor/github.com/vulcand/oxy/forward/rewrite.go index 58720e046..1b71e89f6 100644 --- a/vendor/github.com/vulcand/oxy/forward/rewrite.go +++ b/vendor/github.com/vulcand/oxy/forward/rewrite.go @@ -32,6 +32,12 @@ func (rw *HeaderRewriter) Rewrite(req *http.Request) { req.Header.Set(XForwardedProto, "http") } + if xfp := req.Header.Get(XForwardedPort); xfp != "" && rw.TrustForwardHeader { + req.Header.Set(XForwardedPort, xfp) + } else if req.URL.Port() != "" { + req.Header.Set(XForwardedPort, req.URL.Port()) + } + if xfh := req.Header.Get(XForwardedHost); xfh != "" && rw.TrustForwardHeader { req.Header.Set(XForwardedHost, xfh) } else if req.Host != "" {