diff --git a/caddyconfig/httpcaddyfile/directives.go b/caddyconfig/httpcaddyfile/directives.go index ba8f4387d..4c2b2d91b 100644 --- a/caddyconfig/httpcaddyfile/directives.go +++ b/caddyconfig/httpcaddyfile/directives.go @@ -27,14 +27,21 @@ import ( // directiveOrder specifies the order // to apply directives in HTTP routes. +// +// The root directive goes first in case rewrites or +// redirects depend on existence of files, i.e. the +// file matcher, which must know the root first. +// +// The header directive goes second so that headers +// can be manipulated before doing redirects. var directiveOrder = []string{ + "root", + "header", "redir", "rewrite", - "root", - // URI manipulation "uri", "try_files", diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index 4fd09a231..6666d3eb0 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -199,6 +199,8 @@ func StatusCodeMatches(actual, configured int) bool { // tlsPlaceholderWrapper is a no-op listener wrapper that marks // where the TLS listener should be in a chain of listener wrappers. +// It should only be used if another listener wrapper must be placed +// in front of the TLS handshake. type tlsPlaceholderWrapper struct{} func (tlsPlaceholderWrapper) CaddyModule() caddy.ModuleInfo {