How DDoS Protection Works When Using Cloudflare Proxies?

When your sites are behind Cloudflare, DDoS protection still functions in cPFence, but with some limitations. Here's how it works and what to expect.

How DDoS Protection Is Triggered

cPFence’s IPDB module tracks concurrent connections per IP. DDoS protection is triggered when:

  • An IP reaches 100+ concurrent connections
  • The IP is temporarily blocked for 10 minutes on the first offense
  • If the same IP hits the limit multiple times in one hour, it is permanently blocked

These actions are handled by the IPDB module, not the WAF. Once triggered, the enforcement is passed to the Layer 7 WAF for blocking.

How to View Active Connection Counts

To see the top IPs based on current concurrent connections (as seen by IPDB), run this command:

ss -Htn state established | awk '
  match($4, /^\[?([0-9a-fA-F:.]+)\]?:/, m) {
    ip = m[1]
    cnt[ip]++
  }
  END {
    for (ip in cnt)
      printf "%-20s %5d\n", ip, cnt[ip]
  }
' | sort -k2 -nr | head -20

Cloudflare-Specific Challenges

When using Cloudflare, your server only sees Cloudflare IPs by default. To improve detection:

  • Adjust LiteSpeed to log the real visitor IPs in access logs.
  • cPFence analyzes access logs every 5 minutes to identify abusive IPs.

While helpful, this method is not foolproof due to log parsing delays and masking by proxy headers.

For more on detecting DDos attacks , see:

Am I Under a DDoS Attack?

Why cPFence Doesn't Apply Rate Limiting in WAF as Well?

While it’s technically possible to apply per-IP rate limiting directly inside ModSecurity (WAF), cPFence does not do this by design. This is because applying rate limiting at the WAF level introduces significant performance overhead.

The ModSecurity core team explicitly advises against heavy rate-limiting logic inside the WAF due to its negative impact on server performance and scalability.

For more information, see this discussion:

StackOverflow: Rate Limiting with ModSecurity


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.

 

  • 1 Utilisateurs l'ont trouvée utile
Cette réponse était-elle pertinente?

Articles connexes

How to Fix Bulk IP Blacklisting or Whitelisting Issues in cPFence?

If you're facing issues when attempting to bulk blacklist or whitelist IPs in cPFence, the most...

How to Automate Blocking with Online IP Blacklists in cPFence?

cPFence provides a robust IP Database (IPDB) that dynamically adapts to new threats by updating...

Why cPFence May Not Block Certain Connections?

cPFence is designed to intelligently handle incoming traffic and block malicious or abusive...

Am I Under a DDoS Attack? I See Hundreds of GET Requests in the Logs

Read Also: How to Address High Server Load Issues with cPFence? If you're noticing hundreds of...

Why Does a Whitelisted IP Still Appear in cPFence Stats?

If you’ve whitelisted an IP in cPFence but it still appears in the statistics, there’s no need to...