From 8f9c5f39147120cb18cfcbadba176cdc59c580c0 Mon Sep 17 00:00:00 2001 From: Anders Pitman Date: Mon, 11 Apr 2022 12:14:18 -0600 Subject: [PATCH] Implement X-Forwarded-Proto --- http_proxy.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/http_proxy.go b/http_proxy.go index c63ac6f..572c4df 100644 --- a/http_proxy.go +++ b/http_proxy.go @@ -47,6 +47,12 @@ func proxyRequest(w http.ResponseWriter, r *http.Request, tunnel Tunnel, httpCli upstreamReq.Header = downstreamReqHeaders + scheme := "https" + if r.TLS == nil { + scheme = "http" + } + upstreamReq.Header["X-Forwarded-Proto"] = []string{scheme} + upstreamReq.Header["X-Forwarded-Host"] = []string{r.Host} remoteHost, _, err := net.SplitHostPort(r.RemoteAddr)