about summary refs log tree commit diff stats
path: root/internal
diff options
context:
space:
mode:
authorAlan Pearce2024-12-04 19:56:41 +0100
committerAlan Pearce2024-12-04 19:56:41 +0100
commit60dbf7194e15c8ffafb530769611396ac361640e (patch)
tree08b6dcd3f2ebd927550a5a358802c5f8e801cbd9 /internal
parent996233fb862a6686ae719c91898edc68b5e792a5 (diff)
downloadwebsite-60dbf7194e15c8ffafb530769611396ac361640e.tar.lz
website-60dbf7194e15c8ffafb530769611396ac361640e.tar.zst
website-60dbf7194e15c8ffafb530769611396ac361640e.zip
tls: only redirect to HTTPS if host is known
Diffstat (limited to 'internal')
-rw-r--r--internal/server/tls.go6
1 files changed, 5 insertions, 1 deletions
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