Skip to content

Commit

Permalink
Revert "Only allow some specific headers (#11)" (#14)
Browse files Browse the repository at this point in the history
This reverts commit ce4390d.
  • Loading branch information
tomleb authored Nov 22, 2024
1 parent 020bfb3 commit dc12350
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions proxy/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import (
)

type APIReverseProxy struct {
upstreamURL *url.URL
host string

reverseProxy *httputil.ReverseProxy
}

Expand All @@ -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 {
Expand All @@ -54,6 +38,8 @@ func NewAPIReverseProxy(upstream string, host string) (*APIReverseProxy, error)
}

return &APIReverseProxy{
upstreamURL: upstreamURL,
host: host,
reverseProxy: reverseProxy,
}, nil
}
Expand Down

0 comments on commit dc12350

Please sign in to comment.