Block traffic from specific countries
Last updated Oct 2, 2026
This example custom rule blocks requests based on country code using the ip.src.country field.
- When incoming requests match:
| Field | Operator | Value |
|---|---|---|
| Country | is in | Korea, North |
If you are using the expression editor:
(ip.src.country in {"KP"})
- Then take action: Block
Other resources
- Use case: Block traffic by geographical location
- Use case: Allow traffic from specific countries only
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/waf/custom-rules/use-cases/block-traffic-from-specific-countries/#page","headline":"Block traffic from specific countries","description":"Block traffic from specific countries with a custom rule.","url":"https://developers.cloudflare.com/waf/custom-rules/use-cases/block-traffic-from-specific-countries/","inLanguage":"en","image":"https://developers.cloudflare.com/waf/custom-rules/use-cases/block-traffic-from-specific-countries/og.png?v=46cfeba865d34afb","dateModified":"2026-10-02","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["Geolocation"]}
description: Block or restrict Worker subrequests from other Cloudflare zones. title: Block Worker subrequests from other zones image: https://developers.cloudflare.com/waf/custom-rules/use-cases/block-worker-subrequests/og.png?v=5caf44ada9087388
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/waf/llms.txt
Use this file to discover all available pages before exploring further.
Docs