ModSecurity is a powerful web application firewall (WAF) designed to protect your server and hosted websites from security threats such as SQL injections, cross-site scripting, and other common attacks. This guide explains how to install and configure ModSecurity in WHM.
Below is are steps on how to install ModSecurity on a cPanel server.s
- Login to your server using SSH.
- Uninstall ModSecurity if you had installed it, You cab use the command below
yum remove ea-apache24-mod_security2
- You can then install connectors that that allow mod-security to work with a web-server. Run the appropriate command depending on the web-server that you are using.
- For Apache
yum install ea-modsec30-connector-apache24
- For Nginx
yum install ea-modsec30-connector-nginx
- Now log in to WHM of the Destination Server either with the root account. Normally you will use one of the URLs below;
http://your_server_ip:2087
https://your_server_hostname:2087

- Under the Software section, click on the EasyApache 4.

- Click on the customize button.

- Navigate to Additional Packages and confirm that the controller is installed. If you are working with apache, ensure that modsec30-connector-apache24 is installed. For Nginx, you require modsec30-connector-nginx.

- You now need to enable them by toggling the toggle buttons

- Click on the Next, then on Review then on Provision button to complete the installation.



- Next is to install the OWASP Core Rule Set using the below command.
yum install ea-modsec30-rules-owasp-crs
Configuring ModSecurity #
- In the ModSecurity configuration, you can customize various global settings, including the audit log behavior, rules engine, and connection engine.


- Please see this document or more details
ModSecurity Tools #
ModSecurity Tools provide options for monitoring and managing the firewall rules. You can view all the rules, enable or disable them as needed, and even add new rules as required.

ModSecurity Vendors
The ModSecurity Vendors section allows you to add and manage different rule sets.

For example, you can view, activate, or deactivate the installed OWASP CRS rule set.
Additionally, you can edit or exclude specific rule sets, such as IP reputation or WordPress exclusions, based on your needs.

You can also check the following cPanel Articles regarding ModSecurity.