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 settings easily and ensure they are preserved across cPFence updates.

Step 1: Edit the User Agent Files

To block or whitelist user agents, you need to edit the following files:

 

  • For Blacklisting: /opt/cpfence/app/cpfwaf/userdata_bl_agents
  • For Whitelisting: /opt/cpfence/app/cpfwaf/userdata_wl_agents

 

Add the user agents you want to block or whitelist in the respective files. Each user agent should be on a new line.

Step 2: Apply Your Changes

 

After editing the files, you need to disable and re-enable the Web Application Firewall (WAF) to apply your changes. Run the following commands in your terminal:

 

cpfence --disable-ols-waf
cpfence --enable-ols-waf

 

This will ensure that your changes take effect immediately.

Notes

  • The changes will be preserved even after updating cPFence.
  • whitelist useragent, blacklist useragent
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Enable / Disable WAF Rule by ID ?

This guide provides instructions for enabling and disabling specific WAF rules in cPFence for...

How to Enable / Disable WAF?

This guide provides simple instructions for enabling and disabling the Web Application Firewall...

How to Identify Problematic WAF Rule IDs in cPFence?

When your website encounters a WAF-related error (typically a 403 Forbidden error), you may need...

Whitelisting and Managing WAF Rules in cPFence

To manage the OpenLiteSpeed (OLS)/LiteSpeed (LS) Web Application Firewall (WAF) through cPFence,...

How to Use the cPFence WAF Testing Tool ?

To manually test the WAF (Web Application Firewall) on your WordPress site, you can trigger...