Created
August 27, 2025 14:04
-
-
Save fideloper/af2004b323a4870b2d389e762d631f69 to your computer and use it in GitHub Desktop.
example caddyfile for frankenphp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
{$CADDY_GLOBAL_OPTIONS} | |
admin localhost:{$CADDY_SERVER_ADMIN_PORT} | |
frankenphp { | |
worker "{$APP_PUBLIC_PATH}/frankenphp-worker.php" {$CADDY_SERVER_WORKER_COUNT} | |
} | |
} | |
{$CADDY_SERVER_SERVER_NAME} { | |
log { | |
level {$CADDY_SERVER_LOG_LEVEL} | |
# Redact the authorization query parameter that can be set by Mercure... | |
format filter { | |
wrap {$CADDY_SERVER_LOGGER} | |
fields { | |
uri query { | |
replace authorization REDACTED | |
} | |
} | |
} | |
} | |
route { | |
root * "{$APP_PUBLIC_PATH}" | |
encode zstd br gzip | |
# Mercure configuration is injected here... | |
{$CADDY_SERVER_EXTRA_DIRECTIVES} | |
@static { | |
file | |
path *.js *.css *.jpg *.jpeg *.gif *.png *.ico *.cur *.gz *.svg *.svgz *.mp4 *.mp3 *.ogg *.ogv *.webm *.htc *.woff2 *.woff | |
} | |
@staticshort { | |
file | |
path *.json *.xml *.rss | |
} | |
# 1 year, similar to h5bp nginx config | |
header @static Cache-Control "public, immutable, stale-while-revalidate, max-age=31536000" | |
# 1 hour max, gets validated with the origin server | |
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#no-cache | |
header @staticshort Cache-Control "no-cache, max-age=3600" | |
# Restrict access to dot files and certain file extensions | |
@rejected path *.bak *.conf *.dist *.fla *.ini *.inc *.inci *.log *.orig *.psd *.sh *.sql *.swo *.swp *.swop */.* | |
#@rejected `path('*.bak', '*.conf', '*.dist', '*.fla', '*.ini', '*.inc', '*.inci', '*.log', '*.orig', '*.psd', '*.sh', '*.sql', '*.swo', '*.swp', '*.swop', '*/.*') && !path('*/.well-known/*')` | |
error @rejected 403 | |
php_server { | |
index frankenphp-worker.php | |
# Required for the public/storage/ directory... | |
resolve_root_symlink | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment