Merge pull request #1710 from tuhao1020/master

udpate modifyProxiedRequest
This commit is contained in:
Gerasimos (Makis) Maropoulos 2021-01-23 03:52:21 +02:00 committed by GitHub
commit 0fc80c6813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}