How to limit abusive traffic with Nginx (rate limiting)
Updated 11/29/2026
Rate limiting stops a single IP from making thousands of requests and overloading the server. Nginx has this feature built in.
1. Define a limit zone
In /etc/nginx/nginx.conf, inside the http block:
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
Allows 10 requests per second per IP.
2. Apply the limit
In a server block or a specific location (e.g. the login page):
location /login {
limit_req zone=mylimit burst=20 nodelay;
proxy_pass http://127.0.0.1:3000;
}
3. Reload
nginx -t && systemctl reload nginx
4. Also limit concurrent connections
limit_conn_zone $binary_remote_addr zone=conn:10m;
limit_conn conn 20;
Limitations
Rate limiting stops small abuse, but not a large DDoS attack, which needs network-level protection. Combine with fail2ban and a firewall.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Single sign-on for your applications with authentik
One account for all your team's apps: first sign-in, users, an OpenID Connect application and two-factor authentication.
Updated 11/29/2026SecurityPasswordless sign-in with Pocket ID
Passkeys for your applications over OpenID Connect: first sign-in, colleagues and connecting an application.
Updated 11/29/2026SecurityHow to protect your server from brute-force attacks with fail2ban
fail2ban automatically bans IPs that repeatedly try wrong passwords. Here is how to install and configure it.
Updated 11/29/2026