mirror of
https://github.com/umputun/reproxy.git
synced 2024-11-24 08:12:31 +02:00
fix forwarded url, has to be earlier and constructed
This commit is contained in:
parent
351de86a26
commit
e2ee5bab1b
@ -212,10 +212,13 @@ func (h *Http) proxyHandler() http.HandlerFunc {
|
|||||||
uu := ctx.Value(ctxURL).(*url.URL)
|
uu := ctx.Value(ctxURL).(*url.URL)
|
||||||
keepHost := ctx.Value(ctxKeepHost).(bool)
|
keepHost := ctx.Value(ctxKeepHost).(bool)
|
||||||
r.Header.Add("X-Forwarded-Host", r.Host)
|
r.Header.Add("X-Forwarded-Host", r.Host)
|
||||||
|
scheme := "http"
|
||||||
if h.SSLConfig.SSLMode == SSLAuto || h.SSLConfig.SSLMode == SSLStatic {
|
if h.SSLConfig.SSLMode == SSLAuto || h.SSLConfig.SSLMode == SSLStatic {
|
||||||
h.setHeaderIfNotExists(r, "X-Forwarded-Proto", "https")
|
h.setHeaderIfNotExists(r, "X-Forwarded-Proto", "https")
|
||||||
h.setHeaderIfNotExists(r, "X-Forwarded-Port", "443")
|
h.setHeaderIfNotExists(r, "X-Forwarded-Port", "443")
|
||||||
|
scheme = "https"
|
||||||
}
|
}
|
||||||
|
r.Header.Set("X-Forwarded-URL", fmt.Sprintf("%s://%s%s", scheme, r.Host, r.URL.String()))
|
||||||
r.URL.Path = uu.Path
|
r.URL.Path = uu.Path
|
||||||
r.URL.Host = uu.Host
|
r.URL.Host = uu.Host
|
||||||
r.URL.Scheme = uu.Scheme
|
r.URL.Scheme = uu.Scheme
|
||||||
@ -223,7 +226,6 @@ func (h *Http) proxyHandler() http.HandlerFunc {
|
|||||||
if !keepHost {
|
if !keepHost {
|
||||||
r.Host = uu.Host
|
r.Host = uu.Host
|
||||||
}
|
}
|
||||||
r.Header.Set("X-Forwarded-URL", r.URL.String())
|
|
||||||
h.setXRealIP(r)
|
h.setXRealIP(r)
|
||||||
},
|
},
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
Loading…
Reference in New Issue
Block a user