Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2018-06-22 16:36:04 +0300
committerAlessio Caiazza <acaiazza@gitlab.com>2018-06-22 16:36:04 +0300
commitc4a419ed595281f62977fd47aa30d225c4eddb5d (patch)
treefbc33579fc6f4c4f40e864c18442364c33dc7e77 /app.go
parent4a16516c0ab5742671bdf1cffc13b55a3b4a69b9 (diff)
parent27ef750e6a1053ecd23df55e690235be589f3815 (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.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/app.go b/app.go
index 38738960..5527d1f7 100644
--- a/app.go
+++ b/app.go
@@ -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)
}