fix x-forwarded-for header (#4111)

This commit is contained in:
fatedier
2024-03-28 16:47:27 +08:00
committed by GitHub
parent 86f90f4d27
commit 590ccda677
10 changed files with 203 additions and 50 deletions

View File

@ -59,6 +59,7 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) *
proxy := &httputil.ReverseProxy{
// Modify incoming requests by route policies.
Rewrite: func(r *httputil.ProxyRequest) {
r.Out.Header["X-Forwarded-For"] = r.In.Header["X-Forwarded-For"]
r.SetXForwarded()
req := r.Out
req.URL.Scheme = "http"