From dc1235071f76c7d996900898b64f9e28bb58ba92 Mon Sep 17 00:00:00 2001 From: Tom Lebreux Date: Fri, 22 Nov 2024 18:42:34 -0500 Subject: [PATCH] Revert "Only allow some specific headers (#11)" (#14) This reverts commit ce4390ddd01eb6be3ebfc143daae9b1e5ebe23f9. --- proxy/handlers.go | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/proxy/handlers.go b/proxy/handlers.go index 98c8145..d361e88 100644 --- a/proxy/handlers.go +++ b/proxy/handlers.go @@ -12,6 +12,9 @@ import ( ) type APIReverseProxy struct { + upstreamURL *url.URL + host string + reverseProxy *httputil.ReverseProxy } @@ -24,25 +27,6 @@ func NewAPIReverseProxy(upstream string, host string) (*APIReverseProxy, error) reverseProxy := &httputil.ReverseProxy{ Director: func(req *http.Request) { rewriteRequestURL(req, upstreamURL) - headers := http.Header{} - - allowedHeaders := []string{ - "X-Forwarded-For", - "X-Forwarded-Host", - "X-Forwarded-Proto", - "User-Agent", - } - for _, header := range allowedHeaders { - vals, ok := req.Header[header] - if !ok { - continue - } - - for _, val := range vals { - headers.Add(header, val) - } - } - req.Header = headers req.Host = host }, ModifyResponse: func(resp *http.Response) error { @@ -54,6 +38,8 @@ func NewAPIReverseProxy(upstream string, host string) (*APIReverseProxy, error) } return &APIReverseProxy{ + upstreamURL: upstreamURL, + host: host, reverseProxy: reverseProxy, }, nil }