Browse Source

http: Don't use a Host matcher for HTTP->HTTPS redirects

In case on-demand TLS is enabled, in that case we don't know the only
names that have automatic HTTPS.

See https://caddy.community/t/v2-http-to-https-redirects-fail-for-on-demand-ssl-certs/6742?u=matt
master
Matthew Holt 5 years ago
parent
commit
994b9033e9
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 7
      modules/caddyhttp/caddyhttp.go

7
modules/caddyhttp/caddyhttp.go

@ -486,12 +486,7 @@ func (app *App) automaticHTTPS() error {
// create the route that does the redirect and associate
// it with the listener address it will be served from
lnAddrRedirRoutes[httpRedirLnAddr] = Route{
MatcherSets: []MatcherSet{
{
MatchProtocol("http"),
MatchHost(domains),
},
},
MatcherSets: []MatcherSet{{MatchProtocol("http")}},
Handlers: []MiddlewareHandler{
StaticResponse{
StatusCode: WeakString(strconv.Itoa(http.StatusPermanentRedirect)),

Loading…
Cancel
Save