nextcloud/Caddyfile

97 lines
2.1 KiB
Caddyfile

{
skip_install_trust
{$CADDY_GLOBAL_OPTIONS}
frankenphp {
{$FRANKENPHP_CONFIG}
}
log {
level {$CADDY_LOG_LEVEL:WARN}
}
}
{$CADDY_EXTRA_CONFIG}
:8080 {
log {
output stdout
format json
}
skip_log /health
root * /var/www/html
encode zstd br gzip
header {
Referrer-Policy "no-referrer"
X-Content-Type-Options "nosniff"
X-Frame-Options "SAMEORIGIN"
X-Permitted-Cross-Domain-Policies "none"
X-Robots-Tag "noindex, nofollow"
X-XSS-Protection "1; mode=block"
Strict-Transport-Security "max-age=63072000; includeSubdomains;"
-X-Powered-By
}
# Static asset caching
@static_versioned {
path *.css *.js *.mjs *.svg *.gif *.ico *.jpg *.png *.webp *.wasm *.tflite *.map *.ogg *.flac *.woff *.woff2
query v=*
}
@static_unversioned {
path *.css *.js *.mjs *.svg *.gif *.ico *.jpg *.png *.webp *.wasm *.tflite *.map *.ogg *.flac *.woff *.woff2
not query v=*
}
header @static_versioned Cache-Control "public, max-age=15778463, immutable"
header @static_unversioned Cache-Control "public, max-age=15778463"
# CalDAV / CardDAV
redir /.well-known/carddav /remote.php/dav/ 301
redir /.well-known/caldav /remote.php/dav/ 301
# Well-known handling (mutually exclusive)
handle /.well-known/acme-challenge/* {
file_server
}
handle /.well-known/pki-validation/* {
file_server
}
handle /.well-known/* {
redir /index.php{uri} 301
}
# Notify Push proxy
handle /push/* {
uri strip_prefix /push
reverse_proxy {$NOTIFY_PUSH_UPSTREAM:127.0.0.1:7867}
}
# Health check
respond /health 200
# Block sensitive paths
@blocked_dirs path_regexp ^/(build|tests|config|lib|3rdparty|templates|data)(/|$)
respond @blocked_dirs 404
@blocked_files path_regexp ^/(\.htaccess|autotest|occ|issue|indie|db_|console)
respond @blocked_files 404
# DavClnt redirect at root
@davclient {
path /
header User-Agent "DavClnt*"
}
redir @davclient /remote.php/webdav/ 302
# Legacy /remote alias
@remote path /remote /remote/*
redir @remote /remote.php{uri} 301
php_server {
resolve_root_symlink
}
}