AutoTLS: allow fallback servers to not run on :80

This commit is contained in:
Gerasimos (Makis) Maropoulos 2020-08-13 07:24:46 +03:00
parent 6ead1d21da
commit ff5e43f341
No known key found for this signature in database
GPG Key ID: 5DBE766BD26A54E7
2 changed files with 5 additions and 3 deletions

View File

@ -407,9 +407,11 @@ func (su *Supervisor) runTLS(getCertificate func(*tls.ClientHelloInfo) (*tls.Cer
} else { } else {
if srv.Addr == "" { if srv.Addr == "" {
srv.Addr = ":http" srv.Addr = ":http"
} else if !su.manuallyTLS && srv.Addr != ":80" && srv.Addr != ":http" {
return fmt.Errorf("autotls: The HTTP-01 challenge relies on http://%s:80/.well-known/acme-challenge/", netutil.ResolveVHost(su.Server.Addr))
} }
// } else if !su.manuallyTLS && srv.Addr != ":80" && srv.Addr != ":http" {
// hostname, _, _ := net.SplitHostPort(su.Server.Addr)
// return fmt.Errorf("autotls: The HTTP-01 challenge relies on http://%s:80/.well-known/acme-challenge/", hostname)
// }
if srv.Handler == nil { if srv.Handler == nil {
// handler was nil, caller wanted to change the server's options like read/write timeout. // handler was nil, caller wanted to change the server's options like read/write timeout.

View File

@ -614,7 +614,7 @@ var (
// a valid option when the caller wants just to customize the server's fields (except Addr). // a valid option when the caller wants just to customize the server's fields (except Addr).
// With this host configurator the caller can customize the server // With this host configurator the caller can customize the server
// that letsencrypt relies to perform the challenge. // that letsencrypt relies to perform the challenge.
// LetsEncrypt Certification Manager relies on http://%s:80/.well-known/acme-challenge/<TOKEN>. // LetsEncrypt Certification Manager relies on http://example.com/.well-known/acme-challenge/<TOKEN>.
AutoTLSNoRedirect = func(getFallbackServer func(acmeHandler func(fallback http.Handler) http.Handler) *http.Server) host.Configurator { AutoTLSNoRedirect = func(getFallbackServer func(acmeHandler func(fallback http.Handler) http.Handler) *http.Server) host.Configurator {
return func(su *host.Supervisor) { return func(su *host.Supervisor) {
su.NoRedirect() su.NoRedirect()