From 1b98deb6c9bd09cb28a01738c38943a528ca0f02 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Tue, 8 Sep 2020 14:30:46 -0700 Subject: [PATCH] Set x-forwarded-proto if unset and needed. --- pkg/proxy/proxy.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/proxy/proxy.go b/pkg/proxy/proxy.go index 137c3d6..94f9791 100644 --- a/pkg/proxy/proxy.go +++ b/pkg/proxy/proxy.go @@ -109,12 +109,15 @@ func Handler(prefix string, cfg *rest.Config) (http.Handler, error) { handler = stripLeaveSlash(prefix, handler) } - return authHeaders(handler), nil + return proxyHeaders(handler), nil } -func authHeaders(handler http.Handler) http.Handler { +func proxyHeaders(handler http.Handler) http.Handler { return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { req.Header.Del("Authorization") + if req.Header.Get("X-Forwarded-Proto") == "" && req.TLS != nil { + req.Header.Set("X-Forwarded-Proto", "https") + } handler.ServeHTTP(rw, req) }) }