Skip to content

Whitelisting your IP in ModSecurity on cPanel

How to safely allowlist an office or VPN IP in ModSecurity on cPanel without disabling the rules that are catching real attacks.

ModSecurity is doing its job when it blocks the developer who just pasted an unusual payload into a WordPress admin field. It is not doing its job when the response to that block is “let’s disable rule 949110 site-wide.” A surgical IP allowlist gets the trusted users out of the rule chain without softening the wall for everyone else.

What’s happening

On a cPanel server with the OWASP CRS enabled, common WordPress administrative actions — bulk plugin updates, theme editor saves, certain Gutenberg block payloads, even some WP-CLI operations going through admin-ajax.php — trip paranoia-level rules. The user sees a 403, the server logs a rule match, and the temptation is to disable the rule. Don’t. Allowlist the source instead.

How to verify

First, confirm a real ModSecurity block (not a generic 403 from .htaccess or a plugin). On a cPanel/WHM box:

tail -f /var/log/apache2/modsec_audit.log

A blocked request will look like a multi-section audit entry with Engine-Mode: ENABLED and one or more Message: Warning. ... [id "<rule-id>"] lines. Note the rule ID and the source IP. You can also pull recent blocks from WHM under Security Center → ModSecurity Tools → Hit List.

If the IP is your office or VPN egress and the request is a legitimate WordPress admin action, you have a whitelist candidate. If it’s someone you don’t recognize, the rule is doing its job.

The fix

Add a per-vhost allowlist rule, not a server-wide rule disable. Edit /etc/apache2/conf.d/userdata/std/2_4/<user>/<domain>/modsec.conf (or use WHM Apache Configuration → Include Editor → Pre VirtualHost Include, scoped to the domain) and add:

SecRule REMOTE_ADDR "@ipMatch 203.0.113.10,198.51.100.0/24" \
    "id:1500001,phase:1,nolog,allow,ctl:ruleEngine=Off"

Replace the IPs with the actual office or VPN egress. Then rebuild and reload:

/scripts/rebuildhttpdconf
systemctl reload httpd

Re-test the admin action that was previously blocked, confirm the modsec_audit.log no longer logs a match for that source, and confirm requests from any other IP still hit the rules. If the allowlisted range ever changes — VPN provider rotation, ISP swap — update the rule the same day. A stale whitelist is worse than no whitelist.

For long-lived environments, we keep the ModSecurity ruleset, the allowlist, and the audit log review as part of Deployment & Management.