summaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/caddyhttp.go
diff options
context:
space:
mode:
authorMatthew Holt <[email protected]>2020-01-11 00:33:47 -0700
committerMatthew Holt <[email protected]>2020-01-11 00:33:47 -0700
commit8be1f0ea668492000cdefbd937e0359bdc24bfc1 (patch)
tree0f470cf3d357bcaec6d70d47f11bd83bb636a096 /modules/caddyhttp/caddyhttp.go
parent2eda21ec6d44fa2f57e72ef0f02ea29c902d871d (diff)
downloadcaddy-8be1f0ea668492000cdefbd937e0359bdc24bfc1.tar.gz
caddy-8be1f0ea668492000cdefbd937e0359bdc24bfc1.zip
http: Ensure primary routes always get compiled (fix #2972)
Including servers for HTTP->HTTPS redirects which do not get provisioned like the rest.
Diffstat (limited to 'modules/caddyhttp/caddyhttp.go')
-rw-r--r--modules/caddyhttp/caddyhttp.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go
index ab217cbd4..7381e5144 100644
--- a/modules/caddyhttp/caddyhttp.go
+++ b/modules/caddyhttp/caddyhttp.go
@@ -164,6 +164,7 @@ func (app *App) Provision(ctx caddy.Context) error {
srv.Listen[i] = lnOut
}
+ primaryRoute := emptyHandler
if srv.Routes != nil {
err := srv.Routes.Provision(ctx)
if err != nil {
@@ -171,8 +172,9 @@ func (app *App) Provision(ctx caddy.Context) error {
}
// pre-compile the handler chain, and be sure to wrap it in our
// route handler so that important security checks are done, etc.
- srv.primaryHandlerChain = srv.wrapPrimaryRoute(srv.Routes.Compile())
+ srv.primaryHandlerChain = srv.Routes.Compile()
}
+ srv.primaryHandlerChain = srv.wrapPrimaryRoute(primaryRoute)
if srv.Errors != nil {
err := srv.Errors.Routes.Provision(ctx)
@@ -504,7 +506,7 @@ func (app *App) automaticHTTPS() error {
// if there are HTTP->HTTPS redirects to add, do so now
if len(lnAddrRedirRoutes) > 0 {
var redirServerAddrs []string
- var redirRoutes []Route
+ var redirRoutes RouteList
// for each redirect listener, see if there's already a
// server configured to listen on that exact address; if so,
@@ -539,11 +541,12 @@ func (app *App) automaticHTTPS() error {
// rest of the redirects
if len(redirServerAddrs) > 0 {
app.Servers["remaining_auto_https_redirects"] = &Server{
- Listen: redirServerAddrs,
- Routes: redirRoutes,
- tlsApp: tlsApp, // required to solve HTTP challenge
- logger: app.logger.Named("log"),
- errorLogger: app.logger.Named("log.error"),
+ Listen: redirServerAddrs,
+ Routes: redirRoutes,
+ tlsApp: tlsApp, // required to solve HTTP challenge
+ logger: app.logger.Named("log"),
+ errorLogger: app.logger.Named("log.error"),
+ primaryHandlerChain: redirRoutes.Compile(),
}
}
}