DDOS is crazy recently
The module mod_evasive in Apache that prevents DoS attacks. In lighttpd, mod_evasive can also be used to limit the number of concurrent connections to prevent DDOS attacks.
In lighttpd. add the following code to the conf file to enable mod_evasive. This restriction is not enabled for downloading zip files, mp3 files, and other files. Otherwise, the website cannot be connected when the user downloads more than two files, affects user experience.
Server. modules = (
......
"Mod_evasive"
......
);
$ HTTP ["url"] = ~ ". (Zip | mp3 | mp4 | rar | pdf) $ "{
Evasive. max-conns-per-ip = 2
}
If you want to restrict traffic, you can make the following settings:
# The default value of this parameter is 0, indicating no limit.
Connection. kbytes-per-second = 128
......
$ HTTP ["host"] = "your domain name "{
Server. kbytes-per-secondd = 128
}
Restart lighttpd to take effect.
You can also limit the number of connections at the system level:
Add/etc/systcl. conf
Net. ipv4.tcp _ fin_timeout = 30
Net. ipv4.tcp _ keepalive_time = 1200
Net. ipv4.tcp _ syncookies = 1
Net. ipv4.tcp _ tw_reuse = 1
Net. ipv4.tcp _ tw_recycle = 1
Net. ipv4.ip _ local_port_range = 1024 65000
Net. ipv4.tcp _ max_syn_backlog = 8192
Net. ipv4.tcp _ max_tw_buckets = 5000
Then execute systcl-p.