From 60dbf7194e15c8ffafb530769611396ac361640e Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 4 Dec 2024 19:56:41 +0100 Subject: tls: only redirect to HTTPS if host is known --- internal/server/tls.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'internal') diff --git a/internal/server/tls.go b/internal/server/tls.go index 56c2215..183ce70 100644 --- a/internal/server/tls.go +++ b/internal/server/tls.go @@ -131,7 +131,11 @@ func (s *Server) serveTLS() (err error) { } url.Host = net.JoinHostPort(host, s.config.BaseURL.Port()) } - http.Redirect(w, r, url.String(), http.StatusMovedPermanently) + if slices.Contains(s.config.Domains, r.Host) { + http.Redirect(w, r, url.String(), http.StatusMovedPermanently) + } else { + http.NotFound(w, r) + } }) srv.Handler = httpMux -- cgit 1.4.1