Linux vps server lighttpd limits traffic and defends against DDOS attacks

Source: Internet
Author: User
Tags vps vps server

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.