XenForo Cloudflare Firewall Rule: Ban Country Codes from Registration

CR LEAKS

Administrators
Joined
Mar 25, 2022
Messages
1,485
Credits
28,051
Quickly add a Cloudflare Firewall Rule to block registration from specified countries.

Go to Cloudflare > Firewall > Firewall Rules > Create a firewall rule
Look for small text link as you scroll down to Edit expression

Paste the following rule, making sure to edit the registration URLs to be correct for your installation.

The action is BLOCK but you may also choose to CHALLENGE.

Code:
(http.request.uri.path contains "/register") or (http.request.uri.path contains "/?register" and ip.geoip.country in {"AF" "DZ" "AO" "AM" "AZ" "BH" "BD" "BY" "BJ" "BT" "BA" "BW" "BN" "BG" "BF" "BI" "KH" "CM" "CF" "CV" "TD" "CN" "CG" "CD" "CI" "HR" "CZ" "DJ" "EG" "GQ" "ER" "EE" "ET" "GF" "GA" "GM" "GE" "GH" "GW" "GN" "HT" "HU" "IN" "ID" "IR" "IQ" "JO" "KZ" "KP" "KR" "KE" "XK" "KW" "KG" "LA" "LV" "LB" "LS" "LR" "LY" "LT" "MK" "MG" "MW" "MY" "ML" "MR" "YT" "MD" "MN" "ME" "MA" "MZ" "MM" "NA" "NP" "NE" "NG" "OM" "PK" "PG" "PL" "RO" "QA" "RU" "RW" "SA" "SY" "ZM" "XX" "T1" "ZW" "YE" "EH" "TN" "TM" "AE" "UZ" "TR" "UY" "VN" "UG" "TJ" "SR" "SD" "SZ" "LK" "SS" "VE" "UA" "TG" "SO" "SI" "SL" "RS" "SN" "SK" "TZ" "TH" "TL"})

Deploy

You can then go back to the rule and edit the countries if you want. Below are the countries included in the above code (including Tor).

The above rule is good for blocking a large number of countries but leaving most of the world open. Conversely, If your forum is only open to one (or a few) countries, simply change the rule to: Country is not in [choose country (or countries) to allow from dropdown].

Also, you may choose to make the URI Path more restrictive, ie. /forums/register/
 
Back
Top Bottom