diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-12-12 02:50:02 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2021-12-12 02:50:06 +0300 |
commit | 9b0053ad677e091c625e81b55932304e022e8794 (patch) | |
tree | 48db6a7ebe08866c7812ebc332f2815b10d5bc43 /app.go | |
parent | 9de7e5a03772fa8adc652816319d75306bf33e96 (diff) |
fix: remove duplicate xForwardedHost handler
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 17 |
1 files changed, 1 insertions, 16 deletions
@@ -43,10 +43,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}}) ) @@ -214,17 +210,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 { @@ -317,7 +302,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) |