diff options
author | Alessio Caiazza <acaiazza@gitlab.com> | 2018-06-22 16:36:04 +0300 |
---|---|---|
committer | Alessio Caiazza <acaiazza@gitlab.com> | 2018-06-22 16:36:04 +0300 |
commit | c4a419ed595281f62977fd47aa30d225c4eddb5d (patch) | |
tree | fbc33579fc6f4c4f40e864c18442364c33dc7e77 /app.go | |
parent | 4a16516c0ab5742671bdf1cffc13b55a3b4a69b9 (diff) | |
parent | 27ef750e6a1053ecd23df55e690235be589f3815 (diff) |
Merge branch 'feature/add-support-for-reverse-proxy' into 'master'
Add support for reverse proxy
See merge request gitlab-org/gitlab-pages!99
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -24,8 +24,11 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/metrics" ) -const xForwardedProto = "X-Forwarded-Proto" -const xForwardedProtoHTTPS = "https" +const ( + xForwardedProto = "X-Forwarded-Proto" + xForwardedHost = "X-Forwarded-Host" + xForwardedProtoHTTPS = "https" +) var ( corsHandler = cors.New(cors.Options{AllowedMethods: []string{"GET"}}) @@ -158,6 +161,10 @@ func (a *theApp) ServeProxy(ww http.ResponseWriter, r *http.Request) { forwardedProto := r.Header.Get(xForwardedProto) https := forwardedProto == xForwardedProtoHTTPS + if forwardedHost := r.Header.Get(xForwardedHost); forwardedHost != "" { + r.Host = forwardedHost + } + a.serveContent(ww, r, https) } |