From 4915e980c53991d23d8a7395d01aa01e3acbca8f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 14 Feb 2022 12:39:16 +0100 Subject: [PATCH] providers/proxy: revert Host header behaviour closes #2284 Signed-off-by: Jens Langhammer --- internal/outpost/proxyv2/application/mode_proxy.go | 2 -- internal/outpost/proxyv2/application/mode_proxy_test.go | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/internal/outpost/proxyv2/application/mode_proxy.go b/internal/outpost/proxyv2/application/mode_proxy.go index e4ccf14a3..038a214d8 100644 --- a/internal/outpost/proxyv2/application/mode_proxy.go +++ b/internal/outpost/proxyv2/application/mode_proxy.go @@ -77,7 +77,6 @@ func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) { claims, _ := a.getClaims(r) r.URL.Scheme = ou.Scheme r.URL.Host = ou.Host - r.Host = ou.Host if claims != nil && claims.Proxy != nil && claims.Proxy.BackendOverride != "" { u, err := url.Parse(claims.Proxy.BackendOverride) if err != nil { @@ -85,7 +84,6 @@ func (a *Application) proxyModifyRequest(ou *url.URL) func(req *http.Request) { } else { r.URL.Scheme = u.Scheme r.URL.Host = u.Host - r.Host = u.Host } } a.log.WithField("upstream_url", r.URL.String()).Trace("final upstream url") diff --git a/internal/outpost/proxyv2/application/mode_proxy_test.go b/internal/outpost/proxyv2/application/mode_proxy_test.go index ffdfa978c..79b88f535 100644 --- a/internal/outpost/proxyv2/application/mode_proxy_test.go +++ b/internal/outpost/proxyv2/application/mode_proxy_test.go @@ -22,7 +22,7 @@ func TestProxy_ModifyRequest(t *testing.T) { assert.Equal(t, "frontend", req.Header.Get("X-Forwarded-Host")) assert.Equal(t, "/foo", req.URL.Path) assert.Equal(t, "backend:8012", req.URL.Host) - assert.Equal(t, "backend:8012", req.Host) + assert.Equal(t, "frontend", req.Host) } func TestProxy_ModifyRequest_Claims(t *testing.T) { @@ -50,7 +50,7 @@ func TestProxy_ModifyRequest_Claims(t *testing.T) { assert.Equal(t, "/foo", req.URL.Path) assert.Equal(t, "other-backend:8123", req.URL.Host) - assert.Equal(t, "other-backend:8123", req.Host) + assert.Equal(t, "frontend", req.Host) } func TestProxy_ModifyRequest_Claims_Invalid(t *testing.T) { @@ -78,5 +78,5 @@ func TestProxy_ModifyRequest_Claims_Invalid(t *testing.T) { assert.Equal(t, "/foo", req.URL.Path) assert.Equal(t, "backend:8012", req.URL.Host) - assert.Equal(t, "backend:8012", req.Host) + assert.Equal(t, "frontend", req.Host) }