From cc69d057272cff4b897145d2452e4814eb7c32e0 Mon Sep 17 00:00:00 2001 From: tuhao Date: Fri, 22 Jan 2021 01:11:25 +0800 Subject: [PATCH] udpate modifyProxiedRequest --- core/host/proxy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/host/proxy.go b/core/host/proxy.go index 85db9f94..708156f8 100644 --- a/core/host/proxy.go +++ b/core/host/proxy.go @@ -22,6 +22,7 @@ import ( func ProxyHandler(target *url.URL) *httputil.ReverseProxy { director := func(req *http.Request) { modifyProxiedRequest(req, target) + req.Host = target.Host req.URL.Path = path.Join(target.Path, req.URL.Path) } @@ -40,7 +41,6 @@ func ProxyHandler(target *url.URL) *httputil.ReverseProxy { func modifyProxiedRequest(req *http.Request, target *url.URL) { req.URL.Scheme = target.Scheme req.URL.Host = target.Host - req.Host = target.Host if target.RawQuery == "" || req.URL.RawQuery == "" { req.URL.RawQuery = target.RawQuery + req.URL.RawQuery @@ -72,6 +72,8 @@ func ProxyHandlerRemote(target *url.URL, insecureSkipVerify bool) *httputil.Reve } else { req.URL.Path = path.Join(target.Path, req.URL.Path) } + + req.Host = target.Host } p := &httputil.ReverseProxy{Director: director}