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

[FR]: nginx-limit-conn.conf #3674

Open
aster2709 opened this issue Feb 9, 2024 · 1 comment
Open

[FR]: nginx-limit-conn.conf #3674

aster2709 opened this issue Feb 9, 2024 · 1 comment

Comments

@aster2709
Copy link

aster2709 commented Feb 9, 2024

hi team, fail2ban does the job well for limit based on limit_req_zone but i am struggling to ban limit_conn_zone dos'ers

how can one do that?

the log for rate limited by connection zone looks like this

2024/02/09 07:13:23 [error] 1094206#1094206: *20848 limiting connections by zone "two", client: <ip>, server: <server>, request: <request>, host: <host>

it is limited by limit_conn directive in nginx config

limit_conn two 5;

most limit_req and limit_conn are implemented together, but jail exists only for limit_req

help apprciated

@sebres
Copy link
Contributor

sebres commented Feb 10, 2024

The diff for stock nginx-limit-req filter may look like this:

 failregex = ^%(__prefix_line)slimiting requests, excess: [\d\.]+ by zone "(?:%(ngx_limit_req_zones)s)", client: <HOST>,
+            ^%(__prefix_line)slimiting connections by zone "(?:%(ngx_limit_req_zones)s)", client: <ADDR>,

As long as it is not extended yet, one can achieve this with local-config /etc/fail2ban/filter.d/nginx-limit-req.local:

[Definition]
failregex = %(known/failregex)s
            ^%(__prefix_line)slimiting connections by zone "(?:%(ngx_limit_req_zones)s)", client: <ADDR>,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants