[bugfix] Fix server trying to listen twice on same address when l.e. enabled (#557)

This commit is contained in:
tobi 2022-05-12 11:35:36 +02:00 committed by GitHub
parent 8e30671a62
commit 898d256511
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -91,10 +91,6 @@ func (r *router) Start() {
http.Redirect(rw, r, target, http.StatusTemporaryRedirect) 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. // Start the LetsEncrypt autocert manager HTTP server.
go func() { go func() {
addr := fmt.Sprintf("%s:%d", addr := fmt.Sprintf("%s:%d",
@ -103,8 +99,7 @@ func (r *router) Start() {
) )
logrus.Infof("letsencrypt listening on %s", addr) logrus.Infof("letsencrypt listening on %s", addr)
if err := http.ListenAndServe(addr, r.certManager.HTTPHandler(redirect)); err != nil &&
if err := srv.ListenAndServe(); err != nil &&
err != http.ErrServerClosed { err != http.ErrServerClosed {
logrus.Fatalf("letsencrypt: listen: %s", err) logrus.Fatalf("letsencrypt: listen: %s", err)
} }