{"id":1562,"date":"2015-07-06T22:43:53","date_gmt":"2015-07-06T20:43:53","guid":{"rendered":"https:\/\/www.hostking.host\/blog\/?p=1562"},"modified":"2015-07-06T22:43:53","modified_gmt":"2015-07-06T20:43:53","slug":"how-to-install-mod-evasive-on-cpanel-servers","status":"publish","type":"post","link":"https:\/\/www.hostking.host\/blog\/how-to-install-mod-evasive-on-cpanel-servers\/","title":{"rendered":"How to install mod_evasive on cPanel Servers"},"content":{"rendered":"<p><strong>mod_evasive<\/strong> is an Apache module by Jonathan Zdziarski to provide evasive action in the event of an HTTP DoS or DDoS attack or brute force attack. It is also designed to be a detection and network management tool, and can be easily configured to talk to ipchains, firewalls, routers, and etcetera. mod_evasive presently reports abuses via email and syslog facilities.<\/p>\n<p>This article is using version 1.10.1 (stable). You can grab the latest from <a class=\"urlextern\" title=\"http:\/\/www.zdziarski.com\/\" href=\"http:\/\/www.zdziarski.com\/\" rel=\"nofollow noopener\" target=\"_blank\">Zdziarski<\/a>.<\/p>\n<ol>\n<li class=\"level1\">\n<div class=\"li\">Login to your server as the root user via SSH terminal.<\/div>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Let&#8217;s navigate to the default &#8216;source&#8217; directory and download the latest module for Apache to compile against.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">cd \/usr\/local\/src\/\ncurl -Ls https:\/\/go.khtechs.com\/modevasive &gt; \/usr\/local\/src\/mod_evasive.tar.gz<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Extract the newly downloaded archive and move into it&#8217;s directory.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">tar xf mod_evasive.tar.gz\ncd \/usr\/local\/src\/mod_evasive<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Perform the following command to build the module from it&#8217;s source:<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">\/usr\/local\/apache\/bin\/apxs -i -a -c mod_evasive24.c<\/pre>\n<\/div>\n<\/li>\n<li class=\"level2\">\n<div class=\"li\">Once completed successfully, you should see a few lines of output, ending with:<\/div>\n<\/li>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">[activating module `evasive20' in \/usr\/local\/apache\/conf\/httpd.conf]<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">We also need to tell Apache where to look for mod_evasive&#8217;s configurations. Open Apache&#8217;s configuration file and look for &#8216;LoadModule evasive*&#8217;, right below it add:<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">Include \"\/usr\/local\/apache\/conf\/includes\/mod_evasive.conf\"<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">That created an entry in the Apache configuration, however cPanel&#8217;s EasyApache will remove it on any rebuild\/upgrade unless we distill it.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">\/usr\/local\/cpanel\/bin\/apache_conf_distiller --update<\/pre>\n<\/div>\n<\/li>\n<li class=\"level2\">\n<div class=\"li\">You&#8217;ll receive &#8216;Distilled successfully&#8217; as long as all syntax is correct.<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Now that we know it won&#8217;t be removed from the main configuration, we can add our mod_evasive.conf.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">touch \/usr\/local\/apache\/conf\/includes\/mod_evasive.conf\nnano mod_evasive.conf<\/pre>\n<\/div>\n<\/li>\n<li class=\"level2\">\n<div class=\"li\">When nano opens, add the following (or your custom configuration) to the file:<\/div>\n<\/li>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">&lt;IfModule mod_evasive20.c&gt;\n    DOSHashTableSize    3097\n    DOSPageCount        2\n    DOSSiteCount        50\n    DOSPageInterval     1\n    DOSSiteInterval     1\n    DOSBlockingPeriod   3600\n    DOSLogDir           \"\/var\/log\/mod_evasive\"\n    DOSWhitelist        127.0.0.1\n&lt;\/IfModule&gt;<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Let&#8217;s make the directory for logs.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">touch \/var\/log\/mod_evasive<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Test the configuration syntax to make sure everything is correct.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">\/usr\/local\/apache\/bin\/apachectl configtest\nSyntax OK<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Restart Apache.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">\/scripts\/restartsrv_httpd<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">Check to make sure the evasive module is running.<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">\/usr\/local\/apache\/bin\/apachectl -M | grep evasive<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<li class=\"level1\">\n<div class=\"li\">To ensure EasyApache rebuilds mod_evasive with upgrades of Apache, rebuilds, etc. perform the following:<\/div>\n<ul>\n<li class=\"level2\">\n<div class=\"li\">\n<pre class=\"code\">echo \"\/usr\/local\/apache\/bin\/apxs -i -a -c \/usr\/local\/src\/mod_evasive\/mod_evasive24.c\" &gt;&gt; \/scripts\/after_apache_make_install\nchmod +x \/scripts\/after_apache_make_install<\/pre>\n<\/div>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>You&#8217;re all set!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>mod_evasive is an Apache module by Jonathan Zdziarski to provide evasive action in the event of an HTTP DoS or DDoS attack or brute force attack. It is also designed&hellip;<\/p>\n","protected":false},"author":2,"featured_media":1219,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[88,89],"class_list":["post-1562","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website-and-web-hosting","tag-brute-force","tag-ddos","entry"],"_links":{"self":[{"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/posts\/1562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/comments?post=1562"}],"version-history":[{"count":0,"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/posts\/1562\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/media\/1219"}],"wp:attachment":[{"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/media?parent=1562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/categories?post=1562"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostking.host\/blog\/wp-json\/wp\/v2\/tags?post=1562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}