Skip to content

Commit

Permalink
feat(proxy): flag to keep forawrded headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jul 18, 2023
1 parent 3b15b7c commit ce3e818
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -102,6 +105,10 @@ func rewriter(o *options) func(*httputil.ProxyRequest) {
return
}

if c.TrustForwardedHeaders {
r.SetXForwarded()
}

c.setScheme(r)
c.setHost(r)

Expand Down

0 comments on commit ce3e818

Please sign in to comment.