feat(statuspage): obtain tls certificates on demand for custom domains

With UPTIME_STATUSPAGE_TLS the server serves HTTPS with ACME
certificates for its hosts and for verified custom domains of pages it
may serve, shared by all instances through the API. Plain HTTP answers
ACME challenges and health checks and redirects everything else.

Closes #22

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 08:54:08 +01:00
1 parent 46f1f82481
commit 4d1db0943e
8 files changed
+255 -17

No files matched your search

+11 -2
View File
@@ -11,10 +11,19 @@ import (
// Serve blocks until ctx is cancelled, then marks the instance as draining,
// waits drainDelay for load balancers to notice and shuts down gracefully.
func Serve(ctx context.Context, log *slog.Logger, srv *http.Server, health *Health, drainDelay, timeout time.Duration) error {
return serve(ctx, log, srv, health, drainDelay, timeout, srv.ListenAndServe)
}
// ServeTLS is Serve for a server whose TLSConfig provides certificates.
func ServeTLS(ctx context.Context, log *slog.Logger, srv *http.Server, health *Health, drainDelay, timeout time.Duration) error {
return serve(ctx, log, srv, health, drainDelay, timeout, func() error { return srv.ListenAndServeTLS("", "") })
}
func serve(ctx context.Context, log *slog.Logger, srv *http.Server, health *Health, drainDelay, timeout time.Duration, listen func() error) error {
errc := make(chan error, 1)
go func() {
log.Info("http listening", "addr", srv.Addr)
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
log.Info("http listening", "addr", srv.Addr, "tls", srv.TLSConfig != nil)
if err := listen(); err != nil && !errors.Is(err, http.ErrServerClosed) {
errc <- err
}
close(errc)