Get Paid to Participate - up to $1 per post!     Twitter     Facebook
Hosting Discussion
 

Hosting Discussion > Web Hosting Forums > Hardware and Server Configuration > How to limit requests rate per visitor in engintron
forgot password?



FORUM SUPPORTERS:

Reply


Old
  Post #1 (permalink)   01-13-2019, 07:14 AM
HD Newbie
 
Join Date: Apr 2012
Posts: 10
Send a message via MSN to el5olfaa.com

Status: el5olfaa.com is offline
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 :
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;
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 :
Code:
nano /etc/nginx/common_http.conf
nano /etc/nginx/common_https.conf
In each file search for the needed "location" you want to rate limit it and add the following after "location" line :
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;
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 :
Code:
service nginx reload
That's all .

Good luck

Last edited by el5olfaa.com : 01-13-2019 at 07:19 AM.
 
 
 
Reply

Thread Tools

New Post New Post   Old Post Old Post
Posting Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Sponsored By: