There’s been some discussion about that in other threads:
Fail2ban isn’t designed to work with servers that emit structured logs (such as Caddy’s JSON logs) so you need to configure Caddy to emit common_log
access logs for fail2ban to read.
I’d rather see someone write a Caddy plugin for managing iptables rules directly instead of having an external tool, but I don’t think anyone’s done the work to do that yet.
Someone has written a rate limiting plugin for Caddy, but it’s not as efficient as fail2ban because it rejects requests at the server level, not at the firewall level. caddy-ext/ratelimit at master · RussellLuo/caddy-ext · GitHub