commit 898d256511fdddbc6b5e783116b07fd240b28819
parent 8e30671a62791f50ea61967c43c76af09a56d9f3
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Thu, 12 May 2022 11:35:36 +0200
[bugfix] Fix server trying to listen twice on same address when l.e. enabled (#557)
Diffstat:
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/internal/router/router.go b/internal/router/router.go
@@ -91,10 +91,6 @@ func (r *router) Start() {
http.Redirect(rw, r, target, http.StatusTemporaryRedirect)
})
- // Clone HTTP server but with autocert handler
- srv := r.srv
- srv.Handler = r.certManager.HTTPHandler(redirect)
-
// Start the LetsEncrypt autocert manager HTTP server.
go func() {
addr := fmt.Sprintf("%s:%d",
@@ -103,8 +99,7 @@ func (r *router) Start() {
)
logrus.Infof("letsencrypt listening on %s", addr)
-
- if err := srv.ListenAndServe(); err != nil &&
+ if err := http.ListenAndServe(addr, r.certManager.HTTPHandler(redirect)); err != nil &&
err != http.ErrServerClosed {
logrus.Fatalf("letsencrypt: listen: %s", err)
}