From dc1d8826a2a16deda51ce20ef12bb31e1421bb97 Mon Sep 17 00:00:00 2001 From: Heiko Rothe Date: Sun, 4 Jun 2023 18:04:33 +0200 Subject: [PATCH] ipn/ipnlocal: [serve/funnel] add forwarded host and proto header (#8224) This replicates the headers also sent by the golang reverse proxy by default. Fixes https://github.com/tailscale/tailscale/issues/7061 Signed-off-by: Heiko Rothe --- ipn/ipnlocal/serve.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ipn/ipnlocal/serve.go b/ipn/ipnlocal/serve.go index 7bf4604dd..7972ff089 100644 --- a/ipn/ipnlocal/serve.go +++ b/ipn/ipnlocal/serve.go @@ -447,6 +447,8 @@ func (b *LocalBackend) proxyHandlerForBackend(backend string) (*httputil.Reverse Rewrite: func(r *httputil.ProxyRequest) { r.SetURL(u) r.Out.Host = r.In.Host + r.Out.Header.Set("X-Forwarded-Host", r.In.Host) + r.Out.Header.Set("X-Forwarded-Proto", "https") if c, ok := r.Out.Context().Value(serveHTTPContextKey{}).(*serveHTTPContext); ok { r.Out.Header.Set("X-Forwarded-For", c.SrcAddr.Addr().String()) }