Excluding Headers in Logging

1. Caddy version (caddy version): 2.0+

When you turn on the json logging in Caddy, it logs everything including sensitive headers such as Authorization.

What’s the best way to pick specific information that you may want to exclude or only include certain information. Based on what I’ve seen thus far, I don’t think this is probably doable via the Caddyfile.

Unfortunately it’s not possible in the Caddyfile yet, but it’s on my TODO list for v2.2 to implement that.

For now, you can use the caddy adapt command to adapt your config to JSON, then modify your config to use the filter log encoder to delete fields from the JSON logs.

For example you could delete request>headers to get rid of all the headers which may contain sensitive info. It’s not really possible to delete “all headers except a few of them” right now but I’m also planning to implement an except option to the delete filter soon.

/cc @danlsgiga who is also interested in this feature

3 Likes

Also, for reference, here is the ticket I opened requesting an improvement to the delete filter.

2 Likes

awesome, thanks for the help

This topic was automatically closed after 30 days. New replies are no longer allowed.