Skip to content

Commit

Permalink
Update to Caddyfile using Caddy 2 changes. (#2963)
Browse files Browse the repository at this point in the history
  • Loading branch information
CanntAim authored Oct 4, 2020
1 parent f344a81 commit fdf8840
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions webserver-configs/Caddyfile
Original file line number Diff line number Diff line change
@@ -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
}
rewrite /(\.git|cache|bin|logs|backups|tests)/.* /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
}
rewrite /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ /403

# deny running scripts inside user folder
rewrite {
r /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$
to /403
}
rewrite /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ /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 /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) /403

status 403 /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}

0 comments on commit fdf8840

Please sign in to comment.