about summary refs log tree commit diff stats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/server/server.go16
-rw-r--r--internal/server/tls.go2
2 files changed, 11 insertions, 7 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index e75efd3..556c660 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -8,6 +8,7 @@ import (
 	"net/url"
 	"os"
 	"slices"
+	"strconv"
 	"time"
 
 	"website/internal/builder"
@@ -34,14 +35,15 @@ type Config struct {
 	Root          string `conf:"default:website"`
 	Redirect      bool   `conf:"default:false"`
 	ListenAddress string `conf:"default:localhost"`
-	Port          string `conf:"default:3000,short:p"`
+	Port          int    `conf:"default:3000,short:p"`
+	TLSPort       int    `conf:"default:443"`
 	TLS           bool   `conf:"default:false"`
 }
 
 type Server struct {
 	*http.Server
-	config *cfg.Config
-	tls    bool
+	runtimeConfig *Config
+	config        *cfg.Config
 }
 
 func applyDevModeOverrides(config *cfg.Config, listenAddress string) {
@@ -108,7 +110,7 @@ func New(runtimeConfig *Config) (*Server, error) {
 		return nil, errors.WithMessage(err, "error parsing configuration file")
 	}
 
-	listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, runtimeConfig.Port)
+	listenAddress := net.JoinHostPort(runtimeConfig.ListenAddress, strconv.Itoa(runtimeConfig.Port))
 	top := http.NewServeMux()
 
 	if runtimeConfig.Development {
@@ -193,8 +195,8 @@ func New(runtimeConfig *Config) (*Server, error) {
 				},
 			), 0),
 		},
-		config: config,
-		tls:    runtimeConfig.TLS,
+		config:        config,
+		runtimeConfig: runtimeConfig,
 	}, nil
 }
 
@@ -207,7 +209,7 @@ func (s *Server) serve(tls bool) error {
 }
 
 func (s *Server) Start() error {
-	if err := s.serve(s.tls); err != http.ErrServerClosed {
+	if err := s.serve(s.runtimeConfig.TLS); err != http.ErrServerClosed {
 		return errors.Wrap(err, "error creating/closing server")
 	}
 
diff --git a/internal/server/tls.go b/internal/server/tls.go
index b60f474..afcaab6 100644
--- a/internal/server/tls.go
+++ b/internal/server/tls.go
@@ -42,6 +42,8 @@ func (s *Server) serveTLS() (err error) {
 
 	certmagic.DefaultACME.Agreed = true
 	certmagic.DefaultACME.Email = s.config.Email
+	certmagic.HTTPPort = s.runtimeConfig.Port
+	certmagic.HTTPSPort = s.runtimeConfig.TLSPort
 
 	return certmagic.HTTPS(s.config.Domains, s.Server.Handler)
 }