el5olfaa.com
New member
Hello,
In some cases we need to limit the rate of requests per ip when our website is overloaded or under heavy ddos attack.
Let's follow our instructions to do that :
1) Do the following command on server shell :
2) Go to http section and add this after this line "http {" :
This will limit 1 request per second for every visitor depending on his ip address .
3) Now we need to modify the following files by commands :
In each file search for the needed "location" you want to rate limit it and add the following after "location" line :
For example :
If you need to add a delay instead of getting an error page you need to use "burst" attribute :
Now visitor will be delayed in case of exceeded 1 request per second for a total 10 max delayed requests if exceeded an error page will appear .
4) Reload nginx with new configuration :
That's all .
Good luck
In some cases we need to limit the rate of requests per ip when our website is overloaded or under heavy ddos attack.
Let's follow our instructions to do that :
1) Do the following command on server shell :
Code:
nano /etc/nginx/nginx.conf
2) Go to http section and add this after this line "http {" :
Code:
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s;
3) Now we need to modify the following files by commands :
Code:
nano /etc/nginx/common_http.conf
nano /etc/nginx/common_https.conf
Code:
limit_req zone=mylimit;
For example :
Code:
location /login.php {
limit_req zone=mylimit;
proxy_pass http://my_upstream;
}
If you need to add a delay instead of getting an error page you need to use "burst" attribute :
Code:
limit_req zone=mylimit burst=10;
4) Reload nginx with new configuration :
Code:
service nginx reload
That's all .
Good luck
Last edited: