Blocking Foreign Traffic
A single rule using the ip.country field is enough to block foreign traffic. Once saved, the rule propagates to all edge nodes within seconds.
Recipe 1: Allow only Türkiye
Section titled “Recipe 1: Allow only Türkiye”-
Open Console → WAF → [domain] → Rules.
-
Click New Rule and create the exemption rule first:
- Rule name:
search-allow(3–16 characters, alphanumeric,-and_) - Field: Bot Category (
waf.client.bot_category) · Operator: equals (==) · Value:search - Action: Allow
# Allow verified search engine botsIF waf.client.bot_category == searchTHEN allowThe
allowaction skips the remaining rules for matching requests, so this rule must come before the block rule. - Rule name:
-
Save the rule, then click New Rule again to create the block rule:
- Rule name:
foreign-block - Field: Country (
ip.country) · Operator: not equals (!=) · Value:TR - Action: Block
# Block all traffic from outside TürkiyeIF ip.country != TRTHEN block - Rule name:
-
Save. In the rule list, verify that
search-allowsits aboveforeign-block; if not, drag the row up to reorder. Rules are evaluated top to bottom.
Recipe 2: Block specific countries
Section titled “Recipe 2: Block specific countries”If you want to block only specific countries rather than all foreign traffic, use the in operator. Country codes are 2-letter ISO 3166-1 codes (RU, CN, KP…).
-
Follow Console → WAF → [domain] → Rules → New Rule.
-
Enter the condition:
- Field: Country (
ip.country) · Operator: in list (in) · Value: the country codes to block
# Block traffic only from selected countriesIF ip.country in RU, CN, KPTHEN block - Field: Country (
-
Select Block as the action and save.
Verification
Section titled “Verification”- Connect through a VPN with a foreign location and try to access your site; you should see the HTTP 403 block page.
- On the Rules page, check that the rule’s hit counter is increasing.
- In Console → WAF → [domain] → Analytics, confirm in the country distribution that blocked requests originate abroad.
- Watch Google Search Console for crawl errors over the next few days.