Skip to content

Commit

Permalink
oauthproxy: forward Host header explicitly
Browse files Browse the repository at this point in the history
The proxy should send the requested Host header up so that
CheckOrigin passes correctly on the upstream target's side.

Also see: //github.com/koding/websocketproxy/issues/9
  • Loading branch information
stephen committed Oct 28, 2018
1 parent 10a348c commit 76867e5
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 76867e5

Please sign in to comment.