From 90c816d82bb9fa83154ec97411ace0942f09d63b Mon Sep 17 00:00:00 2001 From: Artyom Pervukhin Date: Tue, 1 Dec 2015 23:52:40 +0300 Subject: [PATCH] Add X-Forwarded-Proto header Guess protocol from redirect-url scheme if present, or from cookie-secure flag value. closes #171 --- oauthproxy.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/oauthproxy.go b/oauthproxy.go index 94f0983ef..3e9b9b83b 100644 --- a/oauthproxy.go +++ b/oauthproxy.go @@ -707,6 +707,14 @@ func (p *OAuthProxy) Authenticate(rw http.ResponseWriter, req *http.Request) int } else { rw.Header().Set("GAP-Auth", session.Email) } + switch { + case p.redirectURL.Scheme != "": + req.Header.Set("X-Forwarded-Proto", p.redirectURL.Scheme) + case p.CookieSecure: + req.Header.Set("X-Forwarded-Proto", "https") + default: + req.Header.Set("X-Forwarded-Proto", "http") + } return http.StatusAccepted }