From 834cb542f0b75606758b14b05c9dfe5edbd796ed Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Fri, 6 Oct 2023 12:57:42 +0800 Subject: [PATCH] Add HTTP_X_FORWARDED_PROTO header --- service/proxy.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service/proxy.go b/service/proxy.go index 4f72b35..7ea2313 100644 --- a/service/proxy.go +++ b/service/proxy.go @@ -50,6 +50,12 @@ func forwardHandler(targetUrl string, writer http.ResponseWriter, request *http. r.Header.Set("X-Real-Ip", clientIP) } } + + if r.TLS == nil { + r.Header.Set("HTTP_X_FORWARDED_PROTO", "http") + } else { + r.Header.Set("HTTP_X_FORWARDED_PROTO", "https") + } } proxy.ServeHTTP(writer, request)