From 2466ed148466ee17fb4da6d2d732e1a16f0469a6 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 16 Jan 2020 11:29:20 -0700 Subject: httpcaddyfile: Group try_files routes together (#2891) This ensures that only the first matching route is used. --- modules/caddyhttp/fileserver/caddyfile.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/caddyhttp/fileserver/caddyfile.go') diff --git a/modules/caddyhttp/fileserver/caddyfile.go b/modules/caddyhttp/fileserver/caddyfile.go index d26b435..67ae4f4 100644 --- a/modules/caddyhttp/fileserver/caddyfile.go +++ b/modules/caddyhttp/fileserver/caddyfile.go @@ -163,5 +163,10 @@ func parseTryFiles(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) result = append(result, makeRoute(try, "")...) } + // ensure that multiple routes (possible if rewrite targets + // have query strings, for example) are grouped together + // so only the first matching rewrite is performed (#2891) + h.GroupRoutes(result) + return result, nil } -- cgit v1.2.3