Skip to content

Commit

Permalink
Merge pull request #2 from samsarahq/stephen/fix-host-header-forwarding
Browse files Browse the repository at this point in the history
oauthproxy: forward Host header explicitly
  • Loading branch information
stephen authored Oct 29, 2018
2 parents 10a348c + 76867e5 commit 11825df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions oauthproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ func setProxyUpstreamHostHeader(proxy *ReverseProxy, target *url.URL) {
req.URL.Opaque = req.RequestURI
req.URL.RawQuery = ""
}
proxy.wsProxy.Director = func(req *http.Request, out http.Header) {
out.Set("Host", target.Host)
}
}
func setProxyDirector(proxy *ReverseProxy) {
director := proxy.Director
Expand All @@ -141,6 +144,11 @@ func setProxyDirector(proxy *ReverseProxy) {
req.URL.Opaque = req.RequestURI
req.URL.RawQuery = ""
}
proxy.wsProxy.Director = func(req *http.Request, out http.Header) {
// The websocket proxy does not forward Host by default.
// See: https://github.com/koding/websocketproxy/issues/9
out.Set("Host", req.Host)
}
}
func NewFileServer(path string, filesystemPath string) (proxy http.Handler) {
return http.StripPrefix(path, http.FileServer(http.Dir(filesystemPath)))
Expand Down

0 comments on commit 11825df

Please sign in to comment.