mirror of
https://github.com/kataras/iris.git
synced 2025-12-21 20:07:04 +00:00
Merge pull request #1710 from tuhao1020/master
udpate modifyProxiedRequest
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
|||||||
func ProxyHandler(target *url.URL) *httputil.ReverseProxy {
|
func ProxyHandler(target *url.URL) *httputil.ReverseProxy {
|
||||||
director := func(req *http.Request) {
|
director := func(req *http.Request) {
|
||||||
modifyProxiedRequest(req, target)
|
modifyProxiedRequest(req, target)
|
||||||
|
req.Host = target.Host
|
||||||
req.URL.Path = path.Join(target.Path, req.URL.Path)
|
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) {
|
func modifyProxiedRequest(req *http.Request, target *url.URL) {
|
||||||
req.URL.Scheme = target.Scheme
|
req.URL.Scheme = target.Scheme
|
||||||
req.URL.Host = target.Host
|
req.URL.Host = target.Host
|
||||||
req.Host = target.Host
|
|
||||||
|
|
||||||
if target.RawQuery == "" || req.URL.RawQuery == "" {
|
if target.RawQuery == "" || req.URL.RawQuery == "" {
|
||||||
req.URL.RawQuery = 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 {
|
} else {
|
||||||
req.URL.Path = path.Join(target.Path, req.URL.Path)
|
req.URL.Path = path.Join(target.Path, req.URL.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.Host = target.Host
|
||||||
}
|
}
|
||||||
p := &httputil.ReverseProxy{Director: director}
|
p := &httputil.ReverseProxy{Director: director}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user