Skip to content

Commit 6a6f920

Browse files
authored
Merge pull request #55 from Remitly/preserve-host-config
sso-proxy: add preserve host configuration option
2 parents c0ce81d + 9f81a78 commit 6a6f920

File tree

4 files changed

+285
-145
lines changed

4 files changed

+285
-145
lines changed

internal/proxy/oauthproxy.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ func NewReverseProxy(to *url.URL, config *UpstreamConfig) *httputil.ReverseProxy
185185
proxy.Director = func(req *http.Request) {
186186
req.Header.Add("X-Forwarded-Host", req.Host)
187187
director(req)
188-
req.Host = to.Host
188+
if !config.PreserveHost {
189+
req.Host = to.Host
190+
}
189191
}
190192
return proxy
191193
}
@@ -214,7 +216,9 @@ func NewRewriteReverseProxy(route *RewriteRoute, config *UpstreamConfig) *httput
214216

215217
req.Header.Add("X-Forwarded-Host", req.Host)
216218
director(req)
217-
req.Host = target.Host
219+
if !config.PreserveHost {
220+
req.Host = target.Host
221+
}
218222
}
219223
return proxy
220224
}

0 commit comments

Comments
 (0)