add debug Printf
This commit is contained in:
parent
b2d6bb7a08
commit
d91f2177f7
|
@ -1,6 +1,7 @@
|
|||
package http01proxy
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
|
@ -24,14 +25,24 @@ func ListenAndServe(target string, timeout time.Duration) error {
|
|||
req.Header.Del("X-Forwarded-For")
|
||||
req.Header.Del("X-Forwarded-Proto")
|
||||
req.Header.Del("X-Forwarded-Port")
|
||||
req.Header.Del("X-Forwarded-Host")
|
||||
|
||||
// We want the incoming host header to remain unchanged,
|
||||
// which is the domain name that is being challenged
|
||||
log.Printf("[debug] Incoming Host: %q", req.Header.Get("Host"))
|
||||
req.Header.Set("X-Forwarded-Host", req.Header.Get("Host"))
|
||||
|
||||
targetQuery := targetURL.RawQuery
|
||||
req.URL.Scheme = targetURL.Scheme
|
||||
// But we want the proxy target to be updated to the new target
|
||||
req.URL.Host = targetURL.Host
|
||||
req.Host = targetURL.Host
|
||||
//req.Header.Set("Host", targetURL.Host)
|
||||
//req.Host = targetURL.Host
|
||||
req.URL.Path, req.URL.RawPath = joinURLPath(targetURL, req.URL)
|
||||
|
||||
log.Printf("[debug] Target Host: %q", req.URL.Host)
|
||||
log.Printf("[debug] Target Path: %q", req.URL.Path)
|
||||
log.Printf("[debug] Target RawPath: %q", req.URL.Path)
|
||||
|
||||
if targetQuery == "" || req.URL.RawQuery == "" {
|
||||
req.URL.RawQuery = targetQuery + req.URL.RawQuery
|
||||
} else {
|
||||
|
|
|
@ -44,6 +44,12 @@ func RouteStatic(r chi.Router) chi.Router {
|
|||
func getACMEChallenges(w http.ResponseWriter, r *http.Request) {
|
||||
//token := chi.URLParam(r, "token")
|
||||
host := r.Host
|
||||
xHost := r.Header.Get("X-Forwarded-Host")
|
||||
fmt.Printf("[debug] Host: %q\n[debug] X-Host: %q", host, xHost)
|
||||
if len(xHost) > 0 {
|
||||
// TODO TrustProxy option?
|
||||
host = xHost
|
||||
}
|
||||
if strings.ContainsAny(host, "/:|\\") {
|
||||
host = ""
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue