diff options
author | Vladimir Shushlin <vshushlin@gitlab.com> | 2022-01-24 15:59:52 +0300 |
---|---|---|
committer | Vladimir Shushlin <vshushlin@gitlab.com> | 2022-01-24 15:59:52 +0300 |
commit | 136471e8d5a582236fb0f9565da3b0114a048b1e (patch) | |
tree | 581a920d824be61b856e341e66a15fee7fa24458 /app.go | |
parent | 88656e8f55e74ea5d7adf703e36dac23726a139b (diff) | |
parent | 9b0053ad677e091c625e81b55932304e022e8794 (diff) |
Merge branch 'fix/xforward-duplicate' into 'master'
fix: remove duplicate xForwardedHost handler
See merge request gitlab-org/gitlab-pages!641
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 17 |
1 files changed, 1 insertions, 16 deletions
@@ -44,10 +44,6 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/metrics" ) -const ( - xForwardedHost = "X-Forwarded-Host" -) - var ( corsHandler = cors.New(cors.Options{AllowedMethods: []string{http.MethodGet, http.MethodHead}}) ) @@ -215,17 +211,6 @@ func (a *theApp) httpInitialMiddleware(handler http.Handler) http.Handler { }) } -// proxyInitialMiddleware sets up proxy requests -func (a *theApp) proxyInitialMiddleware(handler http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if forwardedHost := r.Header.Get(xForwardedHost); forwardedHost != "" { - r.Host = forwardedHost - } - - handler.ServeHTTP(w, r) - }) -} - // setRequestScheme will update r.URL.Scheme if empty based on r.TLS func setRequestScheme(r *http.Request) *http.Request { if r.URL.Scheme == request.SchemeHTTPS || r.TLS != nil { @@ -309,7 +294,7 @@ func (a *theApp) Run() { log.WithError(err).Fatal("Unable to configure pipeline") } - proxyHandler := a.proxyInitialMiddleware(ghandlers.ProxyHeaders(commonHandlerPipeline)) + proxyHandler := ghandlers.ProxyHeaders(commonHandlerPipeline) httpHandler := a.httpInitialMiddleware(commonHandlerPipeline) |