From 65b8a5bb8d55cd13faa783925851251003d72fee Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 9 May 2021 19:12:35 +0200 Subject: [PATCH] outposts/proxy: redirect to protocol based on X-Forwarded-Proto Signed-off-by: Jens Langhammer --- outpost/pkg/proxy/proxy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/outpost/pkg/proxy/proxy.go b/outpost/pkg/proxy/proxy.go index a380f486c..897e97a30 100644 --- a/outpost/pkg/proxy/proxy.go +++ b/outpost/pkg/proxy/proxy.go @@ -344,7 +344,11 @@ func (p *OAuthProxy) AuthenticateOnly(rw http.ResponseWriter, req *http.Request) } if _, ok := req.URL.Query()["traefik"]; ok { host := getHost(req) - http.Redirect(rw, req, fmt.Sprintf("//%s%s", host, p.OAuthStartPath), http.StatusTemporaryRedirect) + proto := req.Header.Get("X-Forwarded-Proto") + if proto != "" { + proto = proto + ":" + } + http.Redirect(rw, req, fmt.Sprintf("%s//%s%s", proto, host, p.OAuthStartPath), http.StatusTemporaryRedirect) return } }