From fdf884036da0c3b613be75e815eaebb6de015722 Mon Sep 17 00:00:00 2001 From: Cant_Aim <4693711+CanntAim@users.noreply.github.com> Date: Sun, 4 Oct 2020 18:35:37 -0400 Subject: [PATCH] Update to Caddyfile using Caddy 2 changes. (#2963) --- webserver-configs/Caddyfile | 41 +++++++++++++++---------------------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git a/webserver-configs/Caddyfile b/webserver-configs/Caddyfile index a3241327f..288f8df8c 100644 --- a/webserver-configs/Caddyfile +++ b/webserver-configs/Caddyfile @@ -1,33 +1,24 @@ :8080 -gzip -fastcgi / 127.0.0.1:9000 php +encode gzip +root * /path/to/grav/root +php_fastcgi unix//run/php/php7.3-fpm.sock +file_server # Begin - Security # deny all direct access for these folders -rewrite { - r /(\.git|cache|bin|logs|backups|tests)/.*$ - to /403 -} -# deny running scripts inside core system folders -rewrite { - r /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ - to /403 -} -# deny running scripts inside user folder -rewrite { - r /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ - to /403 -} -# deny access to specific files in the root folder -rewrite { - r /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) - to /403 -} +rewrite /(\.git|cache|bin|logs|backups|tests)/.* /403 -status 403 /403 +# deny running scripts inside core system folders +rewrite /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ /403 + +# deny running scripts inside user folder +rewrite /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ /403 + +# deny access to specific files in the root folder +rewrite /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) /403 + +respond /403 403 ## End - Security # global rewrite should come last. -rewrite { - to {path} {path}/ /index.php?_url={uri}&{query} -} +try_files {path} {path}/ /index.php?_url={uri}&{query}