1. The problem I’m having:
I would like to continue redacting the Cookie & Set-Cookie headers, however I would like to pull out one specific cookie values in the logs.
I am able to enable logging Cookie/Set-Cookie with servers.log_credentials
and then start redacting any known sensitive cookies, but I’d like to be able to assume all cookies are sensitive by default, and then whitelist a couple values to be output in the logs.
2. Error messages and/or full log output:
{"level":"info","ts":1744122799.5209837,"logger":"http.log.access.log0","msg":"handled request","request":{"remote_ip":"172.18.0.1","remote_port":"57814","client_ip":"172.18.0.1","proto":"HTTP/1.1","method":"GET","host":"localhost:8080","uri":"/","headers":{"Cache-Control":["no-cache"],"Postman-Token":["60d68f72-b526-46c8-82fd-60aa5ede73c7"],"Accept-Encoding":["gzip, deflate, br"],"Connection":["keep-alive"],"Cookie":["myCookie=value;"],"User-Agent":["PostmanRuntime/7.43.3"],"Accept":["*/*"]}},"bytes_read":0,"user_id":"","duration":0.013699417,"size":101,"status":200,"resp_headers":{"Server":["Caddy","Caddy"],"Content-Type":["text/plain; charset=utf-8"],"Date":["Tue, 08 Apr 2025 14:33:19 GMT"],"Content-Length":["101"],"Set-Cookie":[""]}}
3. Caddy version:
Docker image caddy:2.9
4. How I installed and ran Caddy:
I am using a Caddyfile and running caddy run
through Docker.
a. System environment:
MacOS/Docker
b. Command:
`docker run` (`caddy run` under the hood)
c. Service/unit/compose file:
services:
caddy-proxy:
build:
context: ./caddy-proxy
dockerfile: Dockerfile
container_name: caddy-proxy
ports:
- "8080:8080"
d. My complete Caddy config:
{
debug
servers {
log_credentials
}
}
:8080 {
log {
output stdout
format json
level INFO
}
handle /* {
respond "OK" 200
}
}
Edit: for formatting