From ce3e818f3d7f87dc95036f487154223c0d23c321 Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Mon, 17 Jul 2023 23:37:17 +0200 Subject: [PATCH] feat(proxy): flag to keep forawrded headers --- proxy/proxy.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/proxy/proxy.go b/proxy/proxy.go index 15492f86..6ac23e99 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -52,6 +52,9 @@ type ( // PathPrefix is a prefix that is prepended on the original host, // but removed before forwarding. PathPrefix string + // TrustForwardedHosts is a flag that indicates whether the proxy should trust the + // X-Forwarded-* headers or not. + TrustForwardedHeaders bool // originalHost the original hostname the request is coming from. // This value will be maintained internally by the proxy. originalHost string @@ -102,6 +105,10 @@ func rewriter(o *options) func(*httputil.ProxyRequest) { return } + if c.TrustForwardedHeaders { + r.SetXForwarded() + } + c.setScheme(r) c.setHost(r)