cleanup debugging
This commit is contained in:
parent
ea22b856de
commit
8af2fb6cec
|
@ -497,7 +497,7 @@ func parseFlagsAndENVs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proxy for HTTP-01 requests
|
// Proxy for HTTP-01 requests
|
||||||
// TODO needs to be limited to .well-known/acme-challenges
|
// TODO needs to be limited to .well-known/acme-challenge
|
||||||
if len(*proxyHTTP01) > 0 {
|
if len(*proxyHTTP01) > 0 {
|
||||||
go func() {
|
go func() {
|
||||||
fmt.Printf("Proxying HTTP-01 on port 80 to %s\n", *proxyHTTP01)
|
fmt.Printf("Proxying HTTP-01 on port 80 to %s\n", *proxyHTTP01)
|
||||||
|
|
|
@ -127,6 +127,7 @@ func (s *Solver) doRequest(method, uri string, msg interface{}) error {
|
||||||
req.Header.Set("Authorization", "Bearer "+apiToken)
|
req.Header.Set("Authorization", "Bearer "+apiToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fmt.Printf("curl -X %s %s \\\n -H 'Authorization: Bearer %s' \\\n -d '%s'\n\n", method, endpoint.String(), apiToken, string(data))
|
||||||
resp, err := s.config.HTTPClient.Do(req)
|
resp, err := s.config.HTTPClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package http01proxy
|
package http01proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
@ -29,21 +28,31 @@ func ListenAndServe(target string, timeout time.Duration) error {
|
||||||
|
|
||||||
// We want the incoming host header to remain unchanged,
|
// We want the incoming host header to remain unchanged,
|
||||||
// which is the domain name that is being challenged
|
// which is the domain name that is being challenged
|
||||||
log.Printf("[debug] Incoming Host: %q", req.Host)
|
// This is the ORIGINAL req.Header.Host
|
||||||
log.Printf("[debug] Incoming URL.Host: %q", req.URL.Host)
|
//log.Printf("[debug] Incoming Host: %q", req.Host)
|
||||||
log.Printf("[debug] Incoming Header.Host: %q", req.Header.Get("Host"))
|
// This will always be an empty string ""
|
||||||
|
//log.Printf("[debug] Incoming URL.Host: %q", req.URL.Host)
|
||||||
|
// This will always be an empty string ""
|
||||||
|
//log.Printf("[debug] Incoming Header.Host: %q", req.Header.Get("Host"))
|
||||||
|
|
||||||
|
// This will become the HTTP Host header
|
||||||
|
//req.Host
|
||||||
|
|
||||||
targetQuery := targetURL.RawQuery
|
targetQuery := targetURL.RawQuery
|
||||||
req.URL.Scheme = targetURL.Scheme
|
|
||||||
// But we want the proxy target to be updated to the new target
|
|
||||||
//req.Host = targetURL.Host
|
|
||||||
req.URL.Host = targetURL.Host
|
|
||||||
req.URL.Path, req.URL.RawPath = joinURLPath(targetURL, req.URL)
|
|
||||||
|
|
||||||
//log.Printf("[debug] Target Host: %q", req.Host)
|
// This will change the scheme (http/s) used to connect to the target
|
||||||
log.Printf("[debug] Target URL.Host: %q", req.URL.Host)
|
req.URL.Scheme = targetURL.Scheme
|
||||||
log.Printf("[debug] Target URL.Path: %q", req.URL.Path)
|
//log.Printf("[debug] Target URL.Scheme: %q", req.URL.Scheme)
|
||||||
log.Printf("[debug] Target URL.RawPath: %q", req.URL.Path)
|
|
||||||
|
// This will change the network host target
|
||||||
|
// but will NOT change the HTTP Host header
|
||||||
|
req.URL.Host = targetURL.Host
|
||||||
|
//log.Printf("[debug] Target URL.Host: %q", req.URL.Host)
|
||||||
|
|
||||||
|
// This will add the target prefix to the original url
|
||||||
|
req.URL.Path, req.URL.RawPath = joinURLPath(targetURL, req.URL)
|
||||||
|
//log.Printf("[debug] Target URL.Path: %q", req.URL.Path)
|
||||||
|
//log.Printf("[debug] Target URL.RawPath: %q", req.URL.Path)
|
||||||
|
|
||||||
if targetQuery == "" || req.URL.RawQuery == "" {
|
if targetQuery == "" || req.URL.RawQuery == "" {
|
||||||
req.URL.RawQuery = targetQuery + req.URL.RawQuery
|
req.URL.RawQuery = targetQuery + req.URL.RawQuery
|
||||||
|
|
|
@ -44,12 +44,15 @@ func RouteStatic(r chi.Router) chi.Router {
|
||||||
func getACMEChallenges(w http.ResponseWriter, r *http.Request) {
|
func getACMEChallenges(w http.ResponseWriter, r *http.Request) {
|
||||||
//token := chi.URLParam(r, "token")
|
//token := chi.URLParam(r, "token")
|
||||||
host := r.Host
|
host := r.Host
|
||||||
xHost := r.Header.Get("X-Forwarded-Host")
|
/*
|
||||||
log.Printf("[debug] Host: %q\n[debug] X-Host: %q", host, xHost)
|
|
||||||
if len(xHost) > 0 {
|
|
||||||
// TODO TrustProxy option?
|
// TODO TrustProxy option?
|
||||||
|
xHost := r.Header.Get("X-Forwarded-Host")
|
||||||
|
//log.Printf("[debug] Host: %q\n[debug] X-Host: %q", host, xHost)
|
||||||
|
if len(xHost) > 0 {
|
||||||
host = xHost
|
host = xHost
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if strings.ContainsAny(host, "/:|\\") {
|
if strings.ContainsAny(host, "/:|\\") {
|
||||||
host = ""
|
host = ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue