Skip to content

Commit 6a8e5f6

Browse files
bminerzeripath
andauthored
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 <[email protected]>
1 parent ffbd0fe commit 6a8e5f6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/web_letsencrypt.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package cmd
66

77
import (
88
"net/http"
9+
"strconv"
910
"strings"
1011

1112
"code.gitea.io/gitea/modules/log"
@@ -22,6 +23,11 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
2223
// TODO: these are placeholders until we add options for each in settings with appropriate warning
2324
enableHTTPChallenge := true
2425
enableTLSALPNChallenge := true
26+
altHTTPPort := 0
27+
28+
if p, err := strconv.Atoi(setting.PortToRedirect); err == nil {
29+
altHTTPPort = p
30+
}
2531

2632
magic := certmagic.NewDefault()
2733
magic.Storage = &certmagic.FileStorage{Path: directory}
@@ -30,6 +36,8 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
3036
Agreed: setting.LetsEncryptTOS,
3137
DisableHTTPChallenge: !enableHTTPChallenge,
3238
DisableTLSALPNChallenge: !enableTLSALPNChallenge,
39+
ListenHost: listenAddr,
40+
AltHTTPPort: altHTTPPort,
3341
})
3442

3543
magic.Issuers = []certmagic.Issuer{myACME}

0 commit comments

Comments
 (0)