mholt / caddy-ratelimit

HTTP rate limiting module for Caddy 2
Apache License 2.0
255 stars 17 forks source link

Log rate limited IPs #37

Closed jakanaka closed 8 months ago

jakanaka commented 10 months ago

I want to log which IP's are rate limited with date and stuff. Is it already possible now?

mholt commented 10 months ago

Good q -- we don't currently emit logs when a rate limit has been reached.

What would you like to have, specifically?

cf. https://github.com/mholt/caddy-ratelimit/blob/89a7fece9addf6881169642d0b8a18e79d58e179/handler.go#L200

jakanaka commented 10 months ago

Good q -- we don't currently emit logs when a rate limit has been reached.

What would you like to have, specifically?

cf.

https://github.com/mholt/caddy-ratelimit/blob/89a7fece9addf6881169642d0b8a18e79d58e179/handler.go#L200

for me, the time, and the client ip should be enough, it will be even better if it is possible give each ip some sort of reputation based on how frequently it gets rate limited and based on that block that ip for longer time or something, or maybe add how many times it got rate limited

mholt commented 8 months ago

Added in 3d68475 -- let me know if that doesn't work for you!

francislavoie commented 8 months ago

Does this only log the first time the limit is hit, or on every request after? Could be quite noisy and add pressure if they're hitting fast, no?

mholt commented 8 months ago

Log sampling can be configured to tame eccentric logs. But yeah we don't keep any state as to whether it's a first hit or not.