DirectAdmin adds mod_evasive module to optimize Apache performance

DirectAdmin adds mod_evasive module to optimize Apache performance

Time: June 22, 2012 Column: VPS Tutorial Author: Zhao Rong Click: 12363 times

 Proprietary computer room/advanced anti DDoS server/advanced anti DDoS VPS/American advanced anti DDoS/Los Angeles VPS/Los Angeles advanced anti DDoS server

DirectAdmin is a commercial host management panel commonly used by foreign hosts. By default, it uses the Apache engine, which is simple to use and has comprehensive functions. We can also optimize its performance by adding some modules. Zhao Rong shared the addition of Mod_cache module last month( Antecedent review )Today, let's look at another module: mod_evasive

mod_evasive It is the anti DDoS attack module of Apache. When a new access arrives, check whether the customer's IP address is in the blacklist, and HASH the IP address with the request URL; Look up the HASH table to see whether the same page has been requested consecutively in the past 1 second, and HASH the IP and request URL together; Look up the HASH table to see whether more than XX connections have been requested in the past one second; If any one is met, 403 is returned and the IP is blocked for a certain time, which is determined by the DOSSiteInterval. Next, let's see how to install and configure mod_evasive.

********☆☆☆ Installation ☆☆☆********

Log in to the server with root account SSH, and run the following commands in sequence.

wget http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz #Download source code

Tar zxvf mod_evasive_1.10.1. tar. gz # Unzip

Cd mod_evasive # Enter directory

/Usr/sbin/apxs - i - a - c mod_evasive20. c # Install (note that our DA panel Apache version is 2. *)

OK. After the above, mod_evasive has been correctly installed.

********☆☆☆ Configuration ☆☆☆********

At this time, the mod_evasive module has been correctly installed and automatically added to httpd.conf. We can check the file/etc/httpd/conf/httpd.conf and see the following line:

 LoadModule evasive20_module   /usr/lib/httpd/modules/mod_evasive20.so

Next, we configure mod_evasive.

Edit the httpd-evasive.conf file and add rules. SSH operation:

vim /etc/httpd/conf/extra/httpd-evasive.conf

Add the following:

<IfModule mod_evasive20.c>
DOSHAshTableSize 3097 # Define the hash table size.
DOSSiteCount 50 # Maximum concurrent connections allowed for clients.
DOSPageCount 2 # The interval at which clients are allowed to access the same page.
DOSPageInterval 1 # Web page access counter interval.
DOSSiteInterval 1 # Access counter interval of the whole station.
DOSBlockingPeriod 3600 # Access denied time after blacklisting.
DOSEmailNotify # Notify the administrator after an IP is added to the blacklist.
DOSSystemCommand "sudo iptables - A INPUT - s% s - j DROP" # The system command executed after IP is blacklisted.
DOSLogDir "/tmp" # Lock mechanism temporary directory.
DOSWhiteList 127.0.0.1 # Prevent whitelist and do not block whitelist IP addresses.
</IfModule>

Then, save the rule and exit.

Finally, restart httpd.

Service httpd restart # or/etc/init.d/httpd restart

Now, our Apache has added the mod_evasive module.

There is a test script test.pl in the mod_evasive package. You can modify it to test whether it is valid.

Perl test.pl # Test

The above parameters are for reference only. The mod_evasive module also has some advanced functions, which are expected to be discussed. This article takes the DirectAdmin panel as an example. If Apache engine is used in other environments, this module can also be installed.

 Advanced Defense VPS/Los Angeles Advanced Defense/Advanced Defense Server/20 year old computer room

Statement: Blogs are only for sharing information and are not recommendations. Websites do not participate in transactions and are not intermediaries. The content only represents personal views and is not authoritative. Readers should consider it and take their own risks! Every penny and every commodity is still the eternal truth. Juvenile readers (including physical and psychological) should visit this website with their guardians! This article is written by( Zhao Rong )Original compilation, reprint, please keep the link: DirectAdmin adds mod_evasive module to optimize Apache performance The code is not easy, please do not copy or paste!
About using: This website mainly shares server and VPS information, and does not provide any product sales or purchase. All visitors please purchase and use products within the scope of national laws and regulations. QQ group discussion: 683851361
About safety: Any IDC has the possibility of going bankrupt and running away. The host line is even more uncontrollable. Monthly payment and backup are your best choices. Please keep good and regular backup habits

DirectAdmin adds mod_evasive module to optimize Apache performance: there are currently 15 messages

  1. 7th floor
    kite :

    After installation, the 404 file does not exist when you open the website. The environment is nginx+apache, and apache testing is also not good.

    2013-06-17 14:54 [Reply]
    • kite :

      Apache testing is OK, but nginx+Apache is not.

      2013-06-17 15:47 [Reply]
      • Zhao Rong :

        Mod_evasive itself is a module of apache, not nginx.
        I did say that in the article.

        2013-06-17 15:47 [Reply]
        • kite :

          OK, thank you.
          Why don't you use ONE's vps instead of HiChina

          2013-06-17 16:06 [Reply]
          • Zhao Rong :

            Well, hey hey, it's faster at home than abroad

            2013-06-17 16:08 [Reply]
  2. 6th floor
    mano :

    DOSHAshTableSize 3097 # Define the hash table size.
    DOSSiteCount 50 # Maximum concurrent connections allowed for clients.
    DOSPageCount 2 # The interval at which clients are allowed to access the same page.
    DOSPageInterval 1 # Web page access counter interval.
    DOSSiteInterval 1 # Access counter interval of the whole station.
    DOSBlockingPeriod 3600 # Access denied time after blacklisting.
    DOSEmailNotify # Notify the administrator after an IP is added to the blacklist.
    DOSSystemCommand "sudo iptables - A INPUT - s% s - j DROP" # The system command executed after IP is blacklisted.
    DOSLogDir "/tmp" # Lock mechanism temporary directory.
    DOSWhiteList 127.0.0.1 # Prevent whitelist and do not block whitelist IP addresses.

    Can I use this default parameter? It seems that the IP will be disabled if the request speed is a little faster

    2013-02-08 10:26 [Reply]
    • Zhao Rong :

      These parameters are just cases, which should be adjusted according to your actual situation.

      2013-02-08 10:55 [Reply]
  3. 5F
    xing :

    As the blogger said, we are very grateful for the expected effect!

    2013-01-22 22:40 [Reply]
  4. 4th floor
    Yusky :

    。。。 Depressed. What's the problem
    Stop httpd: [Failed]
    Start httpd: httpd: Syntax error on line 132 of/etc/httpd/conf/httpd.conf: Syntax error on line 15 of/etc/httpd/conf/xtra/httpd includes.conf: without matching section

    2012-07-09 01:32 [Reply]
    • Zhao Rong :

      Similarly, the number of error codes in two files clearly tells you

      2012-07-09 06:36 [Reply]
  5. floor
    theend :

    Vim/etc/httpd/conf/xtra/httpd-evasive.conf prompts that the file cannot be found 😕

    2012-07-06 09:24 [Reply]
    • Zhao Rong :

      If not, it means that you have not installed it. If you have installed it, this file will definitely exist.

      2012-07-06 09:25 [Reply]
  6. Bench
    cc :

    DOSEmailNotify ( xx@xx.xx )#Notify the administrator when an IP is added to the blacklist.

    2012-06-23 16:37 [Reply]
  7. sofa
    cc :

    DOSSiteInterval 1 # Access counter interval of the whole station.
    DOSSiteInterval(DOSBlockingPeriod?) 60 # Access denied time after blacklisting.

    seemingly

    2012-06-23 16:35 [Reply]
    • lxmytsm :

      gracefully restaring httpd
      warning :DoumentRoot【/home/admin/96xie.org】does not exist
      httpd: apr_sockaddr_info_get() failed for es-005
      httpd:could not reliably determine theserver’s fully qualified domain name,using 127.0.0.1 for serverName
      []

      2012-11-03 11:53 [Reply]

Comment


 hostyun  locvps

Advertise