|
@@ -2,7 +2,6 @@ package dpcore
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
- "fmt"
|
|
|
"io"
|
|
|
"log"
|
|
|
"net"
|
|
@@ -65,6 +64,7 @@ type ResponseRewriteRuleSet struct {
|
|
|
ProxyDomain string
|
|
|
OriginalHost string
|
|
|
UseTLS bool
|
|
|
+ PathPrefix string //Vdir prefix for root, / will be rewrite to this
|
|
|
}
|
|
|
|
|
|
type requestCanceler interface {
|
|
@@ -353,15 +353,19 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
|
|
|
if strings.HasPrefix(originLocation, "http://") || strings.HasPrefix(originLocation, "https://") {
|
|
|
//Full path
|
|
|
//Replace the forwarded target with expected Host
|
|
|
- fmt.Println(rrr.ProxyDomain, domainWithoutPort, rrr.OriginalHost)
|
|
|
- lr, err := replaceLocationHost(locationRewrite, rrr.OriginalHost, req.TLS == nil)
|
|
|
+ lr, err := replaceLocationHost(locationRewrite, rrr.OriginalHost, req.TLS != nil)
|
|
|
if err == nil {
|
|
|
locationRewrite = lr
|
|
|
}
|
|
|
//locationRewrite = strings.ReplaceAll(locationRewrite, rrr.ProxyDomain, rrr.OriginalHost)
|
|
|
//locationRewrite = strings.ReplaceAll(locationRewrite, domainWithoutPort, rrr.OriginalHost)
|
|
|
+ } else if strings.HasPrefix(originLocation, "/") && rrr.PathPrefix != "" {
|
|
|
+ //Back to the root of this proxy object
|
|
|
+ //fmt.Println(rrr.ProxyDomain, domainWithoutPort, rrr.OriginalHost)
|
|
|
+ locationRewrite = strings.TrimSuffix(rrr.PathPrefix, "/") + originLocation
|
|
|
} else {
|
|
|
//Relative path. Do not modifiy location header
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//Custom redirection to this rproxy relative path
|