[ Web Proxy ]
URL:
Viewing: https://developers.cloudflare.com/waf/custom-rules/use-cases/allow-traffic-from-specific-countries/ [Back]  [Original]

Allow traffic from specific countries only Cloudflare Web Application Firewall (WAF) docsSkip to content
SearchCtrlKLog in
  1. Home
  2. /WAF
  3. /
  4. /Common use cases
  5. /Allow traffic from specific countries only

Allow traffic from specific countries only

Last updated May 5, 2026Copy as MarkdownView as MarkdownAgent setup
OverviewOther resources

This example custom rule blocks requests based on country code using the ip.src.country field, only allowing requests from two countries: United States and Mexico.

  • When incoming requests match:

    Field Operator Value
    Country is not in Mexico, United States

    If you are using the expression editor:
    (not ip.src.country in {"US" "MX"})

  • Then take action: Block

Other resources

PreviousAllow traffic from search engine botsNextBlock Microsoft Exchange Autodiscover requests

Was this helpful?

YesNo
Edit pageReport issue
[]

Web Proxy Viewer  |  New URL  |  Original Page