WAF Custom Rules

Creating custom WAF rules in Cloudflare to filter malicious traffic.

Rule Structure

Field = Value AND/OR Field = Value → Action

Common Rules

# Block known bot IPs
(ip.src eq 192.0.2.0/24) → block

# Rate limit login endpoints
(http.request.uri.path eq "/login") → rate_limit(threshold=20, period=60)

# Challenge traffic from high-risk countries
(cf.geo.country in {"T1" "T2"}) → managed_challenge

Rule Actions

Related