Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx: How to properly setup rate limiting?

Tags:

nginx

After hard google search i couldn't find good information how to limit rate with nginx and debian.

I'm not sure where should i add that filter nginx.conf or default. I added this to default not sure if it's right:

limit_req_zone  $binary_remote_addr  zone=one:10m   rate=1r/s;
server {
   server_name Realesta74.net;

   location / {
     limit_req zone=one burst=5;
  }

}

Is that fine? And also how to test it?

like image 824
ruth23454 Avatar asked Jan 28 '26 09:01

ruth23454


1 Answers

Nginx rate limiting is implemented identically regardless of Linux distribution (Debian, Ubuntu, etc). Nginx officially provides a good tutorial and explaination:

https://www.nginx.com/blog/rate-limiting-nginx/

Testing can be done with multiple-connection URL tools like Siege or Apache Benchmark Tool, and Siege this example uses 30 simultaneous connections to test rate limiting on a web page. 503 responses would show if rate limiting is configured properly:

$ siege -c 30 -r 1 --no-parser https://www.example.com/
like image 82
AnthumChris Avatar answered Jan 31 '26 23:01

AnthumChris