debug: output mismatched backend host

This commit is contained in:
WeebDataHoarder
2025-04-30 03:11:29 +02:00
parent b3cd741bee
commit e46a5c75f8
2 changed files with 4 additions and 2 deletions

View File

@@ -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")

View File

@@ -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)