|
@@ -62,7 +62,8 @@ type ReverseProxy struct {
|
|
|
}
|
|
|
|
|
|
type ResponseRewriteRuleSet struct {
|
|
|
- ProxyDomain string
|
|
|
+ ProxyDomain string
|
|
|
+ OriginalHost string
|
|
|
}
|
|
|
|
|
|
type requestCanceler interface {
|
|
@@ -239,8 +240,6 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
|
|
|
transport = http.DefaultTransport
|
|
|
}
|
|
|
|
|
|
- hostname := req.Header.Get("Host")
|
|
|
-
|
|
|
outreq := new(http.Request)
|
|
|
// Shallow copies of maps, like header
|
|
|
*outreq = *req
|
|
@@ -312,11 +311,11 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
|
|
|
domainWithoutPort = strings.Split(rrr.ProxyDomain, ":")[0]
|
|
|
}
|
|
|
|
|
|
- fmt.Println(hostname)
|
|
|
+ fmt.Println(rrr.OriginalHost)
|
|
|
|
|
|
//Replace the forwarded target with expected Host
|
|
|
- locationRewrite = strings.ReplaceAll(locationRewrite, rrr.ProxyDomain, hostname)
|
|
|
- locationRewrite = strings.ReplaceAll(locationRewrite, domainWithoutPort, hostname)
|
|
|
+ locationRewrite = strings.ReplaceAll(locationRewrite, rrr.ProxyDomain, rrr.OriginalHost)
|
|
|
+ locationRewrite = strings.ReplaceAll(locationRewrite, domainWithoutPort, rrr.OriginalHost)
|
|
|
|
|
|
//Custom redirection to this rproxy relative path
|
|
|
res.Header.Set("Location", locationRewrite)
|