diff --git a/lib/http.go b/lib/http.go index 7d733a3..f301bc1 100644 --- a/lib/http.go +++ b/lib/http.go @@ -135,8 +135,11 @@ func (state *State) handleRequest(w http.ResponseWriter, r *http.Request) { data := challenge.RequestDataFromContext(r.Context()) + lg := state.Logger(r) + backend := state.GetBackend(host) if backend == nil { + lg.Debug("no backend for host", "host", host) http.Error(w, http.StatusText(http.StatusServiceUnavailable), http.StatusServiceUnavailable) return } @@ -154,8 +157,6 @@ func (state *State) handleRequest(w http.ResponseWriter, r *http.Request) { return backend } - lg := state.Logger(r) - cleanupRequest := func(r *http.Request, fromChallenge bool) { if fromChallenge { r.Header.Del("Referer") diff --git a/lib/settings/bind.go b/lib/settings/bind.go index 6e8a83b..ae3f0ac 100644 --- a/lib/settings/bind.go +++ b/lib/settings/bind.go @@ -92,6 +92,7 @@ func (b *Bind) Server(backends map[string]http.Handler, acmeCachePath string) (* swap(http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { backend := utils.SelectHTTPHandler(backends, r.Host) if backend == nil { + slog.Debug("no backend for host", "host", r.Host) http.Error(w, http.StatusText(http.StatusBadGateway), http.StatusBadGateway) } else { backend.ServeHTTP(w, r)