-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
add letsencrypt to Gitea #4189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add letsencrypt to Gitea #4189
Changes from 1 commit
aa3fccb
2771df7
dd01b57
ce3840f
95a4191
c56d4a2
1d0097a
caa2d3a
6bbf48c
42411f8
e5afbb9
6fcb86b
f58c5b4
fd0103f
f09fb9c
75dd8ed
89c5e1c
bfe3769
c195fe1
ceebba5
5c57c62
9169a46
f961204
7a79c2b
60708ca
34b5519
be6b426
793c460
aa80181
77a65fa
d3cbc0c
9112ba2
9042772
3d84f1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,11 +73,12 @@ func runHTTPRedirector() { | |
} | ||
} | ||
|
||
func runLetsEncrypt(listenAddr, domain string, m http.Handler) error { | ||
func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler) error { | ||
certManager := autocert.Manager{ | ||
Prompt: autocert.AcceptTOS, | ||
HostPolicy: autocert.HostWhitelist(domain), | ||
Cache: autocert.DirCache("https"), | ||
Cache: autocert.DirCache(directory), | ||
Email: email, | ||
} | ||
go http.ListenAndServe(":80", certManager.HTTPHandler(nil)) // all traffic coming into HTTP will be redirect to HTTPS automatically | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this also only listen on listenAddr ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the HTTP validation that LetsEncrypt does, their servers need to be able to access port 80 on the server requesting the certificate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you should just write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @flufmonster yes but listening only on listenAddr+":80" should be enough since it will be the facing interface also for web access. If I remember listenAddr is by default 0.0.0.0 so by default we have the same comportment but if someone want to listen only to one interface via configuring listenAddr we shouldn't listen on all interface even for LE. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @sapk I've updated this so it only listens on listenAddr instead of 0.0.0.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be handled in same code as http to https functionality already built into gitea |
||
// required for letsencrypt validation | ||
|
@@ -168,7 +169,7 @@ func runWeb(ctx *cli.Context) error { | |
} | ||
err = runHTTPS(listenAddr, setting.CertFile, setting.KeyFile, context2.ClearHandler(m)) | ||
case setting.LetsEncrypt: | ||
err = runLetsEncrypt(listenAddr, setting.Domain, context2.ClearHandler(m)) | ||
err = runLetsEncrypt(listenAddr, setting.Domain, setting.LetsEncryptDirectory, setting.LetsEncryptEmail, context2.ClearHandler(m)) | ||
case setting.FCGI: | ||
listener, err := net.Listen("tcp", listenAddr) | ||
if err != nil { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,8 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`. | |
- `REDIRECT_OTHER_PORT`: **false**: If true and `PROTOCOL` is https, redirects http requests | ||
on another (https) port. | ||
- `PORT_TO_REDIRECT`: **80**: Port used when `REDIRECT_OTHER_PORT` is true. | ||
- `LETSENCRYPT_DIRECTORY`: **https**: Directory that Letsencrypt will use to cache information such as certs and private keys | ||
- `LETSENCRYPT_EMAIL`: **[email protected]**: Email used by Letsencrypt to notify about problems with issued certificates. (No default) | ||
|
||
## Database (`database`) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This HAS to be behind its own setting (
LETSENCRYPT_ACCEPT_TOS
) 😱 People will not read the comments...