aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Karékinian <greg@karekinian.com>2018-12-11 19:34:35 +0100
committertechknowlogick <hello@techknowlogick.com>2018-12-11 13:34:35 -0500
commit716c2918be9609471e499f5ed42a92078289cdc4 (patch)
tree3a2b178f16a1e31aca408c2b179a04a25794e11c
parent60d7b614fedfc2d0ee091ba2941f97332b46a03a (diff)
downloadgitea-716c2918be9609471e499f5ed42a92078289cdc4.tar.gz
gitea-716c2918be9609471e499f5ed42a92078289cdc4.zip
Backported #5525 Fix the Let's Encrypt handler (#5527)
* Fix the Let's Encrypt handler by listening on a valid address Also handle errors in the HTTP server go routine, return a fatal error when something goes wrong. Thanks to @gbl08ma for finding the actual bug Here is an example of the error handling: 2018/12/11 14:23:07 [....io/gitea/cmd/web.go:87 func1()] [E] Failed to start the Let's Encrypt handler on port 30: listen tcp 0.0.0.0:30: bind: permission denied Closes #5280 * Fix a typo
-rw-r--r--cmd/web.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/cmd/web.go b/cmd/web.go
index 4991721211..b6c014a2e3 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -80,7 +80,13 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
Cache: autocert.DirCache(directory),
Email: email,
}
- go http.ListenAndServe(listenAddr+":"+setting.PortToRedirect, certManager.HTTPHandler(http.HandlerFunc(runLetsEncryptFallbackHandler))) // all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validatio happens here)
+ go func() {
+ log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect)
+ var err = http.ListenAndServe(setting.HTTPAddr+":"+setting.PortToRedirect, certManager.HTTPHandler(http.HandlerFunc(runLetsEncryptFallbackHandler))) // all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here)
+ if err != nil {
+ log.Fatal(4, "Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err)
+ }
+ }()
server := &http.Server{
Addr: listenAddr,
Handler: m,