Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fail2ban to ban ip that hits a lot the rate limiter #451

Open
alexgarel opened this issue Jan 9, 2025 · 2 comments
Open

Use fail2ban to ban ip that hits a lot the rate limiter #451

alexgarel opened this issue Jan 9, 2025 · 2 comments
Assignees

Comments

@alexgarel
Copy link
Member

We can use fail2ban on the proxy to ban ips that are getting too many 429 (rate limiting).
a rule like more than x 429 in y minutes.
It will ban bots without banning legitimate users.

@alexgarel
Copy link
Member Author

This is not so easy as it looks.

Currently fail2ban is only activated on the reverse proxy where we don't have access log, so we are unable to look for 469 (or 444) return code.

More-over the fail2ban included filter to ban on too may rate limit hits, is based upon the nginx error log (which make sense to avoid parsing to many logs), so it have to be set up on the off server.

@alexgarel
Copy link
Member Author

Using fail2ban on the nginx proxy will not resolve the problem as it banning the real incoming ip will still allow requests from it, as it goes through the reverse proxy.

One possible solution is to mount logs from the o*f servers (which are in a separate dataset) in the proxy container, to make them accessible to fail2ban.
It then only requires a changes in the jail definition to grep for the right file.

But I think there is a better solution.

We should follow this best practice on reducing parasitic log on the proxy and add a log which is active only on certain type of status response ($status in nginx).

This way we can only log 401, 403, 404, 469, etc... in special log files (supicious_*.log) and have fail2ban watch those files.

@alexgarel alexgarel self-assigned this Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant