1. The problem I’m having:
Hi, I’m trying to configure access logs sampling for a subset of logs for some specific requests, namely GET /healthz
from Caddyfile
. I just can’t get the config right. Is that even possible with Caddyfile
? If yes, how does it look like? If not, how to configure it through API?
2. Error messages and/or full log output:
No error message or log.
3. Caddy version:
2.8.4
4. How I installed and ran Caddy:
a. System environment:
Docker – through FrankenPHP image (1.2.5-php8.3
), not sure if relevant but I thought I mention it anyway.
b. Command:
n/a
c. Service/unit/compose file:
n/a
d. My complete Caddy config:
{
{$CADDY_GLOBAL_OPTIONS}
admin off
log default {
output stdout
format json
level {$CADDY_SERVER_LOG_LEVEL:INFO}
}
frankenphp {
{$FRANKENPHP_CONFIG}
}
}
{$CADDY_EXTRA_CONFIG}
{$SERVER_NAME:localhost} {
root * public/
encode zstd br gzip
vulcain
{$CADDY_SERVER_EXTRA_DIRECTIVES}
log {
output stdout
level {$CADDY_SERVER_ACCESS_LOG_LEVEL:INFO}
format filter {
wrap json
fields {
request>headers>Cf-Access-Jwt-Assertion replace REDACTED
request>headers>Content-Security-Policy delete
request>headers>Content-Security-Policy-Report-Only delete
}
}
}
# security headers
header * {
Permissions-Policy interest-cohort=() # disable FLoC tracking
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
X-XSS-Protection "0"
Referrer-Policy "strict-origin-when-cross-origin"
-X-Powered-By
-Server
}
handle /version {
respond "{\"version\":\"{$APP_VERSION}\",\"revision\":\"{$APP_REVISION}\"}"
header Content-Type "application/json"
}
php_server
}
5. Links to relevant resources:
Thank you