Try add like the following directives to your nginx webserver configuration to prevent from HTTP flooding attacks by limiting the rate of requests and limiting the number of connections for unique ip address (user) :
1. Edit your naginx config file
nano /etc/nginx/nginx.conf
and search for "http" tag :
http {
##
# Basic Settings
##
2. After "##"add the following directives :
#Limiting the Number of Connections for unique IP
limit_conn_zone $binary_remote_addr zone=limit_per_ip:10m;
limit_conn limit_per_ip 20;
#Limiting the Rate of Requests/s for unique IP
limit_req_zone $binary_remote_addr zone=allips:10m rate=60r/s;
limit_req zone=allips burst=60 nodelay;
3. now should your nginx config file looks like this :
http {
##
# Basic Settings
##
#Limiting the Number of Connections for unique IP
limit_conn_zone $binary_remote_addr zone=limit_per_ip:10m;
limit_conn limit_per_ip 20;
#Limiting the Rate of Requests/s for unique IP
limit_req_zone $binary_remote_addr zone=allips:10m rate=60r/s;
limit_req zone=allips burst=60 nodelay;
. . .
4. Save & exit
CTRL+X then y
5. restart your nginx webserver
service nginx restart
or use :
/etc/init.d/nginx restart
*** The best way to protect your website and server from common DDos attacks is to use incapsula solution : https://www.incapsula.com
1. Edit your naginx config file
nano /etc/nginx/nginx.conf
and search for "http" tag :
http {
##
# Basic Settings
##
2. After "##"add the following directives :
#Limiting the Number of Connections for unique IP
limit_conn_zone $binary_remote_addr zone=limit_per_ip:10m;
limit_conn limit_per_ip 20;
#Limiting the Rate of Requests/s for unique IP
limit_req_zone $binary_remote_addr zone=allips:10m rate=60r/s;
limit_req zone=allips burst=60 nodelay;
3. now should your nginx config file looks like this :
http {
##
# Basic Settings
##
#Limiting the Number of Connections for unique IP
limit_conn_zone $binary_remote_addr zone=limit_per_ip:10m;
limit_conn limit_per_ip 20;
#Limiting the Rate of Requests/s for unique IP
limit_req_zone $binary_remote_addr zone=allips:10m rate=60r/s;
limit_req zone=allips burst=60 nodelay;
. . .
4. Save & exit
CTRL+X then y
5. restart your nginx webserver
service nginx restart
or use :
/etc/init.d/nginx restart
*** The best way to protect your website and server from common DDos attacks is to use incapsula solution : https://www.incapsula.com