Block all countries except a few

(ip.geoip.country ne "BR") or (ip.geoip.country ne "CA") or (ip.geoip.country ne "DE") or (ip.geoip.country ne "US") or (ip.geoip.country ne "GB") or (ip.geoip.country ne "AR") or (ip.geoip.country ne "PT") or (ip.geoip.country ne "CO")

Why the above expression is blocking those countries instead of allowing them?

I want to allow only specific countries to access my website, so I had a rule… country does not equal XX then block…

However it seems to be doing the inverse?

Since nothing on google was helping, I started doing this with nginx:

https://nginxlibrary.com/using-cloudflare-for-country-blocking/

But I have no idea if that’s affect performance a lot…

Hi @vitor,

I would use something like (not ip.geoip.country in {"BR" "CA" "DE" "US" "GB" "AR" "PT" "CO"})

If you want to use your original format, I think you may need AND instead of OR.

6 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.