Skip to content
Snippets Groups Projects
Commit aad40e5b authored by Rohith's avatar Rohith
Browse files

host header in reverse proxy (#70)

* - fixing the host header issue, the default behaviour of reverse proxy is not to set the Host header

* - fixed the keycloak tests to include a endpoint
parent d87fb3e0
No related branches found
No related tags found
No related merge requests found
......@@ -386,6 +386,14 @@ func (r oauthProxy) proxyHandler() gin.HandlerFunc {
return
}
/*
Issue: https://github.com/golang/go/issues/7618
The reverse proxy does not update the Host header of request, as it's assumed the upstream in on the
same domain as the proxy. We could override the Director method, but the latter is easier
*/
cx.Request.Host = r.endpoint.Host
r.upstream.ServeHTTP(cx.Writer, cx.Request)
}
}
......
......@@ -48,6 +48,9 @@ const (
func newFakeKeycloakProxyWithResources(t *testing.T, resources []*Resource) *oauthProxy {
kc := newFakeKeycloakProxy(t)
kc.config.Resources = resources
kc.endpoint = &url.URL{
Host: "127.0.0.1",
}
return kc
}
......@@ -107,6 +110,7 @@ func newFakeKeycloakProxy(t *testing.T) *oauthProxy {
kc := &oauthProxy{
config: newFakeKeycloakConfig(t),
upstream: new(fakeReverseProxy),
endpoint: &url.URL{Host: "127.0.0.1"},
}
kc.router = gin.New()
gin.SetMode(gin.ReleaseMode)
......
package tests
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment