Why my custom WAF rules are not working?

If your custom ModSecurity rules aren’t taking effect, it’s often due to duplicate rule IDs or manual file edits. We recommend using the cPFence WebUI or CLI to add custom rules, which automatically manages unique IDs for you. Manual editing of the rules file is for advanced users only.

Recommended Methods to Add Custom WAF Rules

To avoid ID conflicts and ensure proper loading, add rules using one of these methods rather than editing the file by hand:

 

 

  • WebUI: Go to WAF Management > WAF Controls .
  • CLI: Run cpfence | grep waf and follow the prompts.

These tools place your rules in /opt/cpfence/user-config/cpfwaf/whitelist_ols.conf and assign IDs automatically (6001, 6002, 6003, …).

Common Pitfall: Duplicate Rule IDs

ModSecurity requires each rule to have a unique ID ( In your cPFence Custom rules , use only the 6000+ range!). Duplicate IDs or IDs from a different range in your custom rules file will prevent rules from loading.

How to Check and Fix Duplicate IDs

  1. Open your custom rules file:
    nano /opt/cpfence/user-config/cpfwaf/whitelist_ols.conf
  2. Look for entries with the same id: value. Example:
    SecRule REQUEST_URI "@beginsWith /example-path" "id:6001,phase:1,pass,ctl:ruleEngine=Off"
    SecRule REQUEST_URI "@beginsWith /example-path" "id:6001,phase:1,pass,ctl:ruleEngine=Off"
  3. Remove or renumber duplicates so each rule has a unique ID (e.g., 6001, 6002, 6003).
  4. Save the file and restart your web server.

 


Need Further Assistance?

If you encounter any issues or need additional help, feel free to reach out to our support team via your client portal.

 

  • 0 Корисниците го најдоа ова како корисно
Дали Ви помогна овој одговор?

Понудени резултати

How to Block or Whitelist Certain User Agents ?

This guide will help you block or whitelist specific user agents in cPFence. You can manage these...

How to Enable / Disable WAF Rule by ID ?

This guide provides instructions for enabling and disabling specific WAF (Web Application...

How to Enable / Disable WAF?

The cPFence Web Application Firewall (WAF) now fully supports Apache, Nginx, OLS, and LSWS web...

How to Identify Problematic WAF Rule IDs in cPFence?

New! You can now use an automatic tracking tool to identify problematic WAF rules in real time....

How to Stop XML-RPC Attacks Server-Wide Using the cPFence WAF?

Note: This feature is now part of the WP-AutoShield Module and is active by default and done...