How To Install and Configure ModSecurity™ In cPanel

Spread the love

Automated confrontation bots bombard web programs with malicious requests as soon they go on-line. Attackers target every site and ecommerce store at some point, hoping to find some vulnerability they can exploit to inject code, wrong use resources, or steal info. In 2019, bad robots generated a quarter for all web traffic. cPanel & WHM includes lots of features that help net hosts and site staff to repel bad spiders, including the ModSecurity word wide web application firewall (WAF).

cPanel & WHM has held ModSecurity 2 for numerous years, and in cPanel 92, we introduced help for ModSecurity 3. It should be emphasized that will ModSecurity 3 support will be experimental, but it offers a couple of major advantages:

  • ModSecurity two to three is faster than previous versions.
  • This does not depend concerning Apache and can turn out to be used with other web servers, including NGINX.

In this article, we’re going to look at just what ModSecurity does in addition to how you can mount and configure ModSecurity 2 on cPanel & WHM.

What Is Apache ModSecurity and How Really does It Work?

ModSecurity is a web utility firewall. It monitors incoming web traffic for scourges in real-time, blocking vicious connections before they accomplish applications. ModSecurity is some sort of rule-based firewall; it examines requests to a number of rules, looking available for patterns that match bites such as SQL shot, session hijacking, cross-site scripting, and more.

Rules are usually typically provided as some sort of rule set created by simply a third party, while users can add their own own. The Open World wide web Application Security Project® (OWASP) Core Rule Set is certainly the most widely chosen. It includes rules that will protect web apps versus a wide range in threats, including the OWASP Top Ten, a frequently updated list of the particular most common attacks.

Anyone may be wondering exactly how web-application firewalls differ as a result of the network firewall your own personal server already has. Do you need both? Community firewalls protect servers right from malicious traffic at this network layer, as spoken of in ? How To Perservere a DDoS Attack , which is the reason how to install and additionally configure the Config Hardware Security Firewall  (CSF) by using cPanel & WHM.

Networking firewalls like CSF cannot filter attacks against net applications because they start looking like legitimate web asks for. In contrast, WAFs are usually specialized to work towards the application layer, curious about potentially harmful HTTP needs. If you host internet apps on your cPanel server, it’s a superior idea to use both a network firewall like CSF and a WAF like ModSecurity.

The best way to Install ModSecurity throughout cPanel

To put in ModSecurity 3, you will need root access in order to your server, both regarding the command line using SSH and in WHM. Because ModSecurity 3 assist is experimental, you should first install the EasyApache4 experimental repository.

Log on to your server utilizing SSH and run often the following command:

     yum install ea4-experimental

Following, we’ll install the connection that allows ModSecurity for you to work with a world wide web server. We provide a couple of connectors, one for Apache and one for NGINX. They can be set up in the shell or maybe WHM.

In the disguise, install the relevant plug with one of:

     yum install ea-modsec30-connector-apache24 yum install ea-modsec30-connector-nginx     


  • Browse to the EasyApache4 article, which you will find in the Software area of the sidebar menu.
  • Click Customize under At this time Installed Packages .
  • Select the Additional Packages tab.
  • Click the switch following to modsec30-connector-apache24 or modsec30-connector-nginx
  • Select the Review tab, and click this Provision button at your bottom of the website.

cPanel will right now install the connector and even its dependencies.

cPanel Install ModSecurity3

At last, we’ll install the OWASP Core Rule Set, which you can do for WHM, following the equivalent process as above for you to install the modsec30-rules-owasp-crs? arrangement. You can also install the RPM in often the shell with:

     yum install ea-modsec30-rules-owasp-crs     

Configuring ModSecurity

Many of us have chosen sensible foreclosures that should work around most web hosting scenarios, but we also deliver tools for configuring ModSecurity and its rules on WHM’s Collateral Center .

ModSecurity Configuration

cPanel ModSecurity Configuration

ModSecurity Configuration includes settings to control the behavior of various ModSecurity components, including your audit engine, rules engine unit, and connection engine. In cases where you would like in order to use an external geolocation database or logging application, you can configure the exact relevant paths and binaries in this interface far too.

To learn more with regards to these configuration options, visit our ModSecurity Configuration proof.

ModSecurity Tools

?ModSecurity Tools is the most important interface for monitoring and also configuring the firewall’s principles. The Produces List shows requests that triggered some sort of rule and allows end users to deactivate rules if, perhaps they want to permit similar connections in often the future.

cPanel ModSec 3 Tools

?ModSecurity Tools moreover provides an interface needed for viewing rules and their very own status, editing them, and additionally adding new rules applying ModSecurity’s SecRules language.

ModSecurity Vendors

ModSecurity Vendors includes tools for adding and managing rule televisions. If you followed this instructions in the preceding section, you should see the cPanel-provided OWASP CRS rule set, which a person can activate or disconnect here, as well as controlling automatic updating. A person can also turn on and off groups of rules in the signal set, such as IP reputation, WordPress ® exclusion, plus scanner detection rules.

cPanel ModSec 3 Vendors

Hosting providers may desire to create a bespoke rule set or get one from a thirdparty vendor. ModSecurity Vendors at the same time includes features for incorporating and managing third-party rulesets.

Users who would relatively configure ModSecurity 3 by using its configuration files will definitely find more information in our ModSecurity 3 documents.

Managing ModSecurity through ModSecurity SDBM utility

ModSecurity stores details regarding IPs and requests during the /var/cpanel/secdatadir/ip. pag report. Over time, this computer file may consume excessive hard disk drive space because ModSecurity does not necessarily purge stale data. Whenever you would like your system to automatically clean this cache, install the ModSecurity SDBM utility using:

     yum install ea-modsec-sdbm-util     

cPanel’s maintenance intrigue will trigger the software application automatically if it’s put in, but you can also run it manually along with the following command:

     /scripts/shrink_modsec_ip_database -x     

Simply because a general rule, we all advise system administrators to help let the maintenance scripts handle cache clean-ups. Assuming you do decide for you to run the SDBM instrument utility manually, be guaranteed to restart Apache utilizing:


ModSecurity 3, cPanel, as well as NGINX

Unlike earlier versions, ModSecurity 3 is a standalone tool that will works independently of this webserver. It no more time depends on Apache together with can be integrated along with NGINX on cPanel through EasyApache4’s ea-modsec30-connector-nginx connector.

Having said that, NGINX support on cPanel is experimental, and most of us advise against using it as an Apache substitution for production sites. While we are working on it, NGINX is not even yet a standalone alternate to Apache on cPanel servers, as we describe in ?How to Set up and Manage NGINX regarding cPanel.

We’re committed in order to simplifying and automating world-wide-web site and app web host, including security configuration. Together with cPanel & WHM, it’s straightforward to install as well as manage ModSecurity 3, a good fast, powerful web software firewall that protects programs from a huge range of attacks and weaknesses.

As always, if a person have any feedback as well as comments, please let you know. We are right here to help in your best ways we may. You’ll find us in Discord, the cPanel boards, and Reddit.

Posted by News Monkey