Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

DDoS protection on NGINX

limit_conn
In the http section, the limit_conn_zone shared memory zone is set:
Cod:
limit_conn_zone $binary_remote_addr zone=addr:10m;.



Further, already in the server or location, the number of allowable simultaneous connections from one ip-address is described:
using limit_conn:
Cod:
location /download/ { # file folder
limit_conn addr 1; # we allow no more than one connection from one IP address
}




You can set several limit_conn settings in one config.
Cod:
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;

server {
...
limit_conn perip 10; // set a restriction for IP
limit_conn perserver 100; // set limits for the entire virtual host
}




limit_req
We set the shared memory zone and the maximum number of requests per second in the http section.
Cod:
limit_req_zone $binary_remote_addr zone=one:10m rate=2r/s; # limit 2 requests per second




We set a restriction for certain sections and scripts on the site:
Cod:
server {

...
# search section limitation
location /search/ {
limit_req zone=one burst=5; # burst
indicates the maximum excess of the limit, so if 5 requests came from the address in 1 second, then the next second the request will not be processed, if no bursts are provided then the nodelay parameter is set instead of burst=5
}


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Corrupt SoliderOct 9, 2024 04:44 AM 11 559 Oct 9, 2024 04:44 AM
Last Post: Bastille
by Dudule100Mar 3, 2020 03:08 PM 3 171 Mar 3, 2020 03:08 PM
Last Post: piraticae_sine_nomine
by PrintScreenPTJul 22, 2017 11:57 AM 3 161 Jul 22, 2017 11:57 AM
Last Post: Mr J0keR