diff options
-rw-r--r-- | cmd/server/main.go | 6 | ||||
-rw-r--r-- | internal/server/server.go | 5 | ||||
-rw-r--r-- | internal/server/tls.go | 7 |
3 files changed, 7 insertions, 11 deletions
diff --git a/cmd/server/main.go b/cmd/server/main.go index ca69ba2..be36e3b 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -6,8 +6,8 @@ import ( "os" "os/signal" - "go.alanpearce.eu/x/log" "go.alanpearce.eu/website/internal/server" + "go.alanpearce.eu/x/log" "github.com/ardanlabs/conf/v3" "gitlab.com/tozd/go/errors" @@ -25,6 +25,10 @@ func main() { } log := log.Configure(!runtimeConfig.Development) + if listenAddress := runtimeConfig.ListenAddress; listenAddress[0] == '[' { + runtimeConfig.ListenAddress = listenAddress[1 : len(listenAddress)-1] + } + if runtimeConfig.Development { tmpdir, err := os.MkdirTemp("", "website") if err != nil { diff --git a/internal/server/server.go b/internal/server/server.go index 203c5c5..8523bc9 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -15,9 +15,9 @@ import ( "go.alanpearce.eu/website/internal/builder" cfg "go.alanpearce.eu/website/internal/config" - "go.alanpearce.eu/x/log" "go.alanpearce.eu/website/internal/vcs" "go.alanpearce.eu/website/internal/website" + "go.alanpearce.eu/x/log" "github.com/ardanlabs/conf/v3" "github.com/osdevisnot/sorvor/pkg/livereload" @@ -134,7 +134,6 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) { applyDevModeOverrides(config, runtimeConfig) } - listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, strconv.Itoa(runtimeConfig.Port)) top := http.NewServeMux() err = rebuild(builderConfig, config, log) @@ -210,7 +209,6 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) { ReadTimeout: 1 * time.Minute, WriteTimeout: 2 * time.Minute, IdleTimeout: 10 * time.Minute, - Addr: listenAddress, Handler: top, }, redirectServer: &http.Server{ @@ -218,7 +216,6 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) { ReadTimeout: 1 * time.Minute, WriteTimeout: 2 * time.Minute, IdleTimeout: 10 * time.Minute, - Addr: listenAddress, Handler: rMux, }, log: log, diff --git a/internal/server/tls.go b/internal/server/tls.go index 655455c..cd2bfb8 100644 --- a/internal/server/tls.go +++ b/internal/server/tls.go @@ -56,16 +56,11 @@ func (s *Server) serveTLS() (err error) { // caddy's ACME server (step-ca) doesn't specify an OCSP server cfg.OCSP.DisableStapling = true - listenAddress := s.runtimeConfig.ListenAddress - if listenAddress[0] == '[' { - listenAddress = listenAddress[1 : len(listenAddress)-1] - } - issuer = certmagic.NewACMEIssuer(cfg, certmagic.ACMEIssuer{ CA: s.runtimeConfig.ACMECA, TrustedRoots: cp, DisableTLSALPNChallenge: true, - ListenHost: listenAddress, + ListenHost: s.runtimeConfig.ListenAddress, AltHTTPPort: s.runtimeConfig.Port, AltTLSALPNPort: s.runtimeConfig.TLSPort, }) |