{"id":3105,"date":"2014-01-16T20:34:46","date_gmt":"2014-01-16T20:34:46","guid":{"rendered":"http:\/\/blog.shineservers.com\/?p=2408"},"modified":"2014-01-16T20:34:46","modified_gmt":"2014-01-16T20:34:46","slug":"protect-apache-using-mod_security-on-rhelcentos-fedora","status":"publish","type":"post","link":"https:\/\/www.shineservers.com\/2014\/01\/16\/protect-apache-using-mod_security-on-rhelcentos-fedora\/","title":{"rendered":"Protect Apache using Mod_Security on RHEL\/CentOS &#038; Fedora"},"content":{"rendered":"<p>These two great security modules protect\u00a0<strong>Apache<\/strong>\u00a0server from brute force attacks and DOS attacks. Before, moving for further installation guide, we would like to provide you a little description on these tow modules.<\/p>\n<h3>What is Mod_Security?<\/h3>\n<p><strong>Mod_Security<\/strong>\u00a0is an open source web application firewall (<strong>WAF<\/strong>) and intrusion detection and prevention system for web applications. It is used to protect and monitor real time HTTP traffic and web applications from brute fore attacks.<\/p>\n<h3>What is Mod_Evasive?<\/h3>\n<p><strong>Mod_Evasive<\/strong>\u00a0is an open source evasive maneuvers system for\u00a0<strong>Apache<\/strong>\u00a0server to provide evasive action in the event of an HTTP brute force, Dos or DDos attack. It was designed to use as a network traffic detection and network management tool and can be easily configured and integrated into firewalls, ipchains, routers etc. Presently, it sends abuses reports via email and syslog facilites.<\/p>\n<div align=\"center\"><strong>Install\u00a0<\/strong><strong>Mod_Security<\/strong>\u00a0and\u00a0<strong>Mod_evasive<\/strong>\u00a0on\u00a0<strong>RHEL 6.2\/6.1\/6\/5.8<\/strong>,\u00a0<strong>CentOS 6.2\/6.1\/6\/5.8<\/strong>\u00a0and\u00a0<strong>Fedora 17,16,15,14,13,12<\/strong><\/div>\n<h3>How to Install Mod_Security on RHEL\/CentOS &amp; Fedora<\/h3>\n<h4>Step 1: Installing Dependencies for mod_security<\/h4>\n<p>Firstly, we required to install some dependency packages for mod_security. Run the following commands on your selected OS.<\/p>\n<pre><strong>## For RHEL\/CentOS 6.2\/6.1\/6\/5.8 ##<\/strong>\n# yum install gcc make\n# yum install libxml2 libxml2-devel httpd-devel pcre-devel curl-devel\n\n<strong>## For Fedora 17,16,15,14,13,12 ##<\/strong>\n# yum install gcc make\n# yum install libxml2 libxml2-devel httpd-devel pcre-devel curl-devel<\/pre>\n<h4>Step 2: Installing Mod_Security<\/h4>\n<p>As I said above that we use source code to install mod_security. Run the following commands as root.<\/p>\n<pre><strong>## For RHEL\/CentOS 6.2\/6.1\/6\/5.8 ##<\/strong>\n# cd \/usr\/src\n# wget http:\/\/www.modsecurity.org\/download\/modsecurity-apache_2.6.6.tar.gz\n# tar xzf modsecurity-apache_2.6.6.tar.gz\n# cd modsecurity-apache_2.6.6\n# .\/configure\n# make install\n# cp modsecurity.conf-recommended \/etc\/httpd\/conf.d\/modsecurity.conf\n\n<strong>## For Fedora 17,16,15,14,13,12 ##<\/strong>\n# cd \/usr\/src\n# wget http:\/\/www.modsecurity.org\/download\/modsecurity-apache_2.6.6.tar.gz\n# tar xzf modsecurity-apache_2.6.6.tar.gz\n# cd modsecurity-apache_2.6.6\n# .\/configure\n# make install\n# cp modsecurity.conf-recommended \/etc\/httpd\/conf.d\/modsecurity.conf<\/pre>\n<h4>Step 3: Downloading OWASP Mod_Security Core Rule Set<\/h4>\n<p>Mod_Security requires OWASP (Open Web Application Security Project) core rules for base configuration, these rules are used to protect from unknown vulnerabilities which often found on web applications. So, here we are going to download and install rule set for mod_security. Run the following commands.<\/p>\n<pre><strong>## For RHEL\/CentOS 6.2\/6.1\/6\/5.8 ##<\/strong>\n# cd \/etc\/httpd\/\n# wget http:\/\/pkgs.fedoraproject.org\/repo\/pkgs\/mod_security_crs\/modsecurity-crs_2.2.5.tar.gz\/aaeaa1124e8efc39eeb064fb47cfc0aa\/modsecurity-crs_2.2.5.tar.gz\n# tar xzf modsecurity-crs_2.2.5.tar.gz\n# mv modsecurity-crs_2.2.5 modsecurity-crs\n# cd modsecurity-crs\n# cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf<strong>## For Fedora 17,16,15,14,13,12 ##<\/strong>\n# cd \/etc\/httpd\/\n# wget http:\/\/pkgs.fedoraproject.org\/repo\/pkgs\/mod_security_crs\/modsecurity-crs_2.2.5.tar.gz\/aaeaa1124e8efc39eeb064fb47cfc0aa\/modsecurity-crs_2.2.5.tar.gz\n# tar xzf modsecurity-crs_2.2.5.tar.gz\n# mv modsecurity-crs_2.2.5 modsecurity-crs\n# cd modsecurity-crs\n# cp modsecurity_crs_10_setup.conf.example modsecurity_crs_10_config.conf<\/pre>\n<h4>Step 4: Configuring Mod_Security<\/h4>\n<p>Now, you need to modify your Apache configuration file to load the mod_security module.<\/p>\n<pre># vi \/etc\/httpd\/conf\/httpd.conf<\/pre>\n<p>Search for the line\u00a0<strong>LoadModule<\/strong>\u00a0in your httpd.conf and add this below line at the bottom.<\/p>\n<pre>LoadModule security2_module modules\/mod_security2.so<\/pre>\n<p>Now set the basic rule set in your httpd.conf file. Add the following lines of code at the end of the file.<\/p>\n<pre>&lt;IfModule security2_module&gt;\n    Include conf.d\/modsecurity.conf\n &lt;\/IfModule&gt;<\/pre>\n<p>Next, restart the Apache service to enable mod_security module and their rules.<\/p>\n<pre># \/etc\/init.d\/httpd restart<\/pre>\n<p>For more information on this topic visit the following links for your reference.<\/p>\n<ol type=\"circle\">\n<li><a href=\"http:\/\/www.modsecurity.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">ModSecurity Home Page<\/a><\/li>\n<li><a href=\"https:\/\/www.owasp.org\/index.php\/Category:OWASP_ModSecurity_Core_Rule_Set_Project#tab=Installation\" target=\"_blank\" rel=\"noopener noreferrer\">OWASP ModSecurity Core Rule Set<\/a><\/li>\n<\/ol>\n<p>The above installation is tested on CentOS 5.6 and successfully worked for me, I hope it will also work for you, now let\u2019s move further installation of mod_evasive module.<\/p>\n<h3 class=\"zemanta-related-title\" style=\"margin: 0 0 10px 0; padding: 0; clear: both;\">Related articles across the web<\/h3>\n<ul class=\"zemanta-article-ul zemanta-article-ul-image\" style=\"margin: 0; padding: 0; overflow: hidden;\">\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.madjoudj.com\/2013\/12\/getting-started-with-modsecurity-for.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/noimg_6_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.madjoudj.com\/2013\/12\/getting-started-with-modsecurity-for.html\" target=\"_blank\" rel=\"noopener noreferrer\">Getting started with ModSecurity for Nginx<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.madjoudj.com\/2013\/12\/nginx-with-modsecurity-support-repo-for.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/noimg_1_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.madjoudj.com\/2013\/12\/nginx-with-modsecurity-support-repo-for.html\" target=\"_blank\" rel=\"noopener noreferrer\">Nginx with mod_security support repo for Fedora 20 and EPEL6<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/www.daniweb.com\/web-development\/php\/threads\/471258\/modsecurity-pcre-limits-with-no-regular-expressions\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/noimg_1_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/www.daniweb.com\/web-development\/php\/threads\/471258\/modsecurity-pcre-limits-with-no-regular-expressions\" target=\"_blank\" rel=\"noopener noreferrer\">ModSecurity &#8211; PCRE limits with no Regular Expressions<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.spiderlabs.com\/2013\/09\/modsecurity-for-java-beta-testers-needed.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/206294214_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.spiderlabs.com\/2013\/09\/modsecurity-for-java-beta-testers-needed.html\" target=\"_blank\" rel=\"noopener noreferrer\">ModSecurity for Java &#8211; BETA Testers Needed<\/a><\/li>\n<li class=\"zemanta-article-ul-li-image zemanta-article-ul-li\" style=\"padding: 0; background: none; list-style: none; display: block; float: left; vertical-align: top; text-align: left; width: 104px; font-size: 12px; margin: 0 5px 10px 0;\"><a style=\"padding: 2px; display: block; text-decoration: none;\" href=\"http:\/\/blog.spiderlabs.com\/2014\/01\/setting-honeytraps-with-modsecurity-adding-fake-html-comments.html\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" style=\"border-radius: 3px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); padding: 0; margin: 0; border: 0; display: block; width: 100px; max-width: 100%;\" alt=\"\" src=\"http:\/\/i.zemanta.com\/238928103_150_150.jpg\" \/><\/a><a style=\"display: block; overflow: hidden; text-decoration: none; line-height: 12pt; height: 80px; padding: 5px 2px 0 2px;\" href=\"http:\/\/blog.spiderlabs.com\/2014\/01\/setting-honeytraps-with-modsecurity-adding-fake-html-comments.html\" target=\"_blank\" rel=\"noopener noreferrer\">Setting HoneyTraps with ModSecurity: Adding Fake HTML Comments<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>These two great security modules protect\u00a0Apache\u00a0server from brute force attacks and DOS attacks. Before, moving for further installation guide, we would like to provide you a little description on these tow modules. What is Mod_Security? Mod_Security\u00a0is an open source web application firewall (WAF) and intrusion detection and prevention system for web applications. It is used [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[53],"tags":[],"class_list":["post-3105","post","type-post","status-publish","format-standard","hentry","category-general"],"acf":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/3105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/comments?post=3105"}],"version-history":[{"count":0,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/posts\/3105\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/media?parent=3105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/categories?post=3105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shineservers.com\/wp-json\/wp\/v2\/tags?post=3105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}