How to limit abusive traffic with Nginx (rate limiting)
Updated 10/16/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
How to check which ports are open on your server
Find out which services are listening for connections on your server and close what you do not need, for less exposure.
Updated 10/16/2026SecurityHow to scan your server for malware with ClamAV
Install ClamAV, an open-source antivirus, and periodically scan your server for infected files.
Updated 10/16/2026SecurityHow to set up your own VPN with WireGuard
Run your own private, fast and secure VPN with WireGuard on a VPS, for private browsing and secure access.
Updated 10/16/2026