Methods and code for improving the anti-DDOS capability of Discuz

Source: Internet
Author: User

Because of the special nature of the admincp file. When a new connection is generated. It will occupy a lot of system resources. Therefore, when multiple IP addresses continuously access the admincp. php file, the server is vulnerable to DDOS attacks.

Solution:
In the beginning of the admincp. php file <? Add the following code to php: if (preg_replace ("/https? : // ([^/] +). */I "," \ 1 ", $ HTTP_SERVER_VARS ['HTTP _ referer'])! = $ HTTP_SERVER_VARS ['HTTP _ host']) {
Exit ('Warning ---- your operation has been disabled. ');
} Extension. Adding the same code to each file header in the same way can greatly improve the anti-ddos capability of the Forum:
Add the index. php header to if (preg_replace ("/https? : // ([^/] +). */I "," \ 1 ", $ HTTP_SERVER_VARS ['HTTP _ referer'])! = $ HTTP_SERVER_VARS ['HTTP _ host']) {
Exit ('click to enter the forum. <A href = "http://www.freediscuz.com '> http://www.freediscuz.com/index.php"> http://www.freediscuz.com </a> ');
} Add the following code to other PHP file headers in the Forum root directory: if (preg_replace ("/https? : // ([^/] +). */I "," \ 1 ", $ HTTP_SERVER_VARS ['HTTP _ referer'])! = $ HTTP_SERVER_VARS ['HTTP _ host']) {
Exit ('Warning ---- your operation has been disabled. <A href = "http://www.freediscuz.com '> http://www.freediscuz.com/index.php"> http://www.freediscuz.com </a> ');

}
After this modification, everyone accessing your forum must click a link on the homepage to access the Forum. If it is a DDOS attack Forum, the information sent by attackers will not be transmitted to the php program of the Forum. This greatly saves system resources and greatly increases the anti-DDOS capability of the Forum. Especially in unix systems, the defense capability is even several times higher. Of course, if you want to completely defend against DDOS attacks, it is best to block IP access, but we usually lease space, the Administrator will not easily block the IP address, so this is the only thing you can do.

Change the address in the code to your forum address.

Related Article

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.