Toby Chui 1 год назад
Родитель
Сommit
ca6699612d
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      mod/dynamicproxy/dpcore/dpcore.go

+ 2 - 2
mod/dynamicproxy/dpcore/dpcore.go

@@ -238,6 +238,8 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
 		transport = http.DefaultTransport
 	}
 
+	hostname := req.Host
+
 	outreq := new(http.Request)
 	// Shallow copies of maps, like header
 	*outreq = *req
@@ -309,8 +311,6 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
 			domainWithoutPort = strings.Split(rrr.ProxyDomain, ":")[0]
 		}
 
-		hostname := req.Header.Get("Host")
-
 		//Replace the forwarded target with expected Host
 		locationRewrite = strings.ReplaceAll(locationRewrite, rrr.ProxyDomain, hostname)
 		locationRewrite = strings.ReplaceAll(locationRewrite, domainWithoutPort, hostname)