diff options
author | Blake Miner <miner.blake@gmail.com> | 2021-05-12 15:58:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-12 20:58:55 +0100 |
commit | 6a8e5f69cfd6c99f830db577ca2f1af033187645 (patch) | |
tree | 13fe93c2fadb4f077fb503dfe0c9fad6fa19dfa8 /cmd | |
parent | ffbd0fef06fd05ef789c7ff1009686940b127883 (diff) | |
download | gitea-6a8e5f69cfd6c99f830db577ca2f1af033187645.tar.gz gitea-6a8e5f69cfd6c99f830db577ca2f1af033187645.zip |
Fix bound address/port for caddy's certmagic library (#15758)
* Fix bound address/port for caddy's certmagic library
* Fix bug
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/web_letsencrypt.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/web_letsencrypt.go b/cmd/web_letsencrypt.go index 387aacce2c..9cfc9b3ab2 100644 --- a/cmd/web_letsencrypt.go +++ b/cmd/web_letsencrypt.go @@ -6,6 +6,7 @@ package cmd import ( "net/http" + "strconv" "strings" "code.gitea.io/gitea/modules/log" @@ -22,6 +23,11 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler) // TODO: these are placeholders until we add options for each in settings with appropriate warning enableHTTPChallenge := true enableTLSALPNChallenge := true + altHTTPPort := 0 + + if p, err := strconv.Atoi(setting.PortToRedirect); err == nil { + altHTTPPort = p + } magic := certmagic.NewDefault() magic.Storage = &certmagic.FileStorage{Path: directory} @@ -30,6 +36,8 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler) Agreed: setting.LetsEncryptTOS, DisableHTTPChallenge: !enableHTTPChallenge, DisableTLSALPNChallenge: !enableTLSALPNChallenge, + ListenHost: listenAddr, + AltHTTPPort: altHTTPPort, }) magic.Issuers = []certmagic.Issuer{myACME} |