File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Adapted from https://caddy.community/t/caddyfile-for-drupal-10/21607/5
2+ {
3+ {$CADDY_GLOBAL_OPTIONS}
4+
5+ frankenphp {
6+ {$FRANKENPHP_CONFIG}
7+ }
8+
9+ # https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
10+ order php_server before file_server
11+ order php before file_server
12+ }
13+
14+ {$CADDY_EXTRA_CONFIG}
15+
16+ {$SERVER_NAME:localhost } {
17+ root * web /
18+ encode zstd br gzip
19+
20+ @hiddenPhpFilesRegexp path_regexp \..*/ .* \.php$
21+ error @hiddenPhpFilesRegexp 403
22+
23+ @notFoundPhpFiles path_regexp /vendor/.* \.php$
24+ error @notFoundPhpFiles 404
25+
26+ @notFoundPhpFilesRegexp path_regexp ^/sites/ [^/]+/files/.* \.php$
27+ error @notFoundPhpFilesRegexp 404
28+
29+ @privateDirRegexp path_regexp ^/sites/.*/private/
30+ error @privateDirRegexp 403
31+
32+ @protectedFilesRegexp {
33+ not path /.well-known*
34+ path_regexp \.(engine|inc|install|make|module|profile|po|sh|.*sql |theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^/(\..*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock)|web\.config|yarn\.lock|package\.json)$|^\/#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$
35+ }
36+ error @protectedFilesRegexp 403
37+
38+ @static {
39+ file
40+ path *.avif *.css *.eot *.gif *.gz *.ico *.jpg *.jpeg *.js *.otf *.pdf *.png *.svg *.ttf *.webp *.woff *.woff2
41+ }
42+ header @static Cache-Control "max-age=31536000,public,immutable"
43+
44+ {$CADDY_SERVER_EXTRA_DIRECTIVES}
45+
46+ php_server
47+ }
You can’t perform that action at this time.
0 commit comments