{"id":1923,"date":"2018-10-29T00:54:45","date_gmt":"2018-10-29T00:54:45","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw92\/?p=1923"},"modified":"2018-10-31T03:19:18","modified_gmt":"2018-10-31T03:19:18","slug":"modsecurity-installation-with-apache-on-centos","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/29\/modsecurity-installation-with-apache-on-centos\/","title":{"rendered":"ModSecurity Installation With Apache On CentOS"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/linuxadmin.io\/wp-content\/uploads\/2017\/05\/mod_security-2.png\" alt=\"Install ModSecurity With Apache On CentOS\" width=\"667\" height=\"113\" \/><\/p>\n<p>ModSecurity is an open source monitoring system for web applications. It has powerful rule sets that allow you to protect applications from attacks. View the <a href=\"https:\/\/www.modsecurity.org\/\">project<\/a> for more details. It provides a ton of features such as:<\/p>\n<p>More than 16,000 specific rules, broken out into the following attack categories:<br \/>\n* SQL injection<br \/>\n* Cross-site Scripting (XSS)<br \/>\n* Local File Include<br \/>\n* Remote File Include<\/p>\n<p>User option for application specific rules, covering the same vulnerability classes for applications such as:<br \/>\n* WordPress<br \/>\n* cPanel<br \/>\n* osCommerce<br \/>\n* Joomla<\/p>\n<h3>Install ModSecurity<\/h3>\n<p>To get started you will need to have Apache installed. If you do not yet, please see <a href=\"https:\/\/linuxadmin.io\/compile-apache-2-4-source\/\">Compile Apache 2.4 From Source<\/a><\/p>\n<p>Install the required dependencies:<\/p>\n<p>yum install -y libxml libxml-devel<\/p>\n<p>Get the software package:<\/p>\n<p>cd \/usr\/src; wget https:\/\/github.com\/SpiderLabs\/ModSecurity\/releases\/download\/v2.9.1\/modsecurity-2.9.1.tar.gz<\/p>\n<p>Un-compress the archive:<\/p>\n<p>tar xfvz modsecurity-2.9.1.tar.gz<\/p>\n<p>Go in to the directory:<\/p>\n<p>cd modsecurity-2.9.1<\/p>\n<p>Configure it:<\/p>\n<p>.\/configureInstall:make &amp;&amp; make install<\/p>\n<p>You will need to edit \/etc\/httpd\/conf\/httpd.conf and load the module:<\/p>\n<p>LoadModule security2_module lib\/apache\/mod_security2.so<\/p>\n<p>For each domain you want to enable it for add the following:<\/p>\n<p>SecEngine On<\/p>\n<p>Restart Apache to load it:<\/p>\n<p>service httpd restart<\/p>\n<p>Verify it is loading in Apache:<\/p>\n<p>httpd -M 2&gt;&amp;1|grep security<\/p>\n<p>You should see the following returned:<\/p>\n<p>security2_module (shared)<\/p>\n<h3>Configure ModSecurity<\/h3>\n<p>Get a starting ruleset. View the <a href=\"https:\/\/github.com\/SpiderLabs\/owasp-modsecurity-crs\">github project<\/a> for more details.<\/p>\n<p>Download the ruleset:<\/p>\n<p>cd \/usr\/src;wget https:\/\/github.com\/SpiderLabs\/owasp-modsecurity-crs\/archive\/v3.0.0.tar.gz<\/p>\n<p>Un-compress the archive:<\/p>\n<p>tar xfvz v3.0.0.tar.gz<\/p>\n<p>Make a configuration directory<\/p>\n<p>mkdir \/etc\/httpd\/conf\/modsecurity.d<\/p>\n<p>Enter the directory:<\/p>\n<p>cd owasp-modsecurity-crs-3.0.0<\/p>\n<p>Move the rules directory into place:<\/p>\n<p>mv rules\/ \/etc\/httpd\/conf\/modsecurity.d<\/p>\n<p>Move and rename the main configuration:<\/p>\n<p>mv crs-setup.conf.example \/etc\/httpd\/conf\/modsecurity.d\/crs-setup.conf<\/p>\n<p>Review crs-setup.conf and remove comments for any applicable lines.<\/p>\n<p>Edit \/etc\/httpd\/conf\/httpd.conf once again and add the following:<\/p>\n<p>&lt;IfModule security2_module&gt;<br \/>\nInclude \/etc\/httpd\/conf\/modsecurity.d\/crs-setup.conf<br \/>\nInclude \/etc\/httpd\/conf\/modsecurity.d\/rules\/*.conf<br \/>\n&lt;\/IfModule&gt;<\/p>\n<p>Restart Apache once more to load the base configuration. That is it for the base installation. There are numerous ways you can configure it to protect your server from web based attacks and proactively monitor your server.<\/p>\n<p>May 4, 2017LinuxAdmin.io<\/p>\n<p><a href=\"https:\/\/linuxadmin.io\/mod_security-installation-apache-centos\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ModSecurity is an open source monitoring system for web applications. It has powerful rule sets that allow you to protect applications from attacks. View the project for more details. It provides a ton of features such as: More than 16,000 specific rules, broken out into the following attack categories: * SQL injection * Cross-site Scripting &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2018\/10\/29\/modsecurity-installation-with-apache-on-centos\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ModSecurity Installation With Apache On CentOS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1923","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=1923"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1923\/revisions"}],"predecessor-version":[{"id":2038,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/1923\/revisions\/2038"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=1923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=1923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=1923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}