Firewall Rule - All countries blocked EXCEPT

Suppose, I want my website to be accessible only in a few(3) countries, and not be accessible to the rest of the world. How do I set it up in the CloudFlare.

I have seen 403 Forbidden errors offered by cloudflare, popping up, when I accessed certain e-commerce websites which their owners blocked in my country. How do I set it up?

I already know about the firewall rule function offered by Cloudflare, but It takes forever to add each country one by one, to add to My custom list of blocked countries.

All I want is, my website be accessible in 3 countries and blocked to be viewed by anyone in the rest of the world.

If anyone can suggest something, much much appreciated!

3 Likes

@aWaRa, for broad nets like the one you are implementing, it’s also a good idea to add to the rule some exceptions. For instance you may want to add to the rule suggested by @erictung exclusions for known bots (Google and other search engine crawlers), as well as for some files that may be requested by advertisers, such as robots.txt and ads.txt.

2 Likes

Sweet!! Thank You Eric

2 Likes

Thank you for adding value. Sounds invaluable.
I’m a novice in all this, hardly a year. I don’t really know much about technicals. Can you also explain why do I need to exclude the known bots (Google and others), and why the advertisers?
In plain English, I guess I don’t even want to be found on Google by someone outside my chosen countries. So, if your suggestion is about being found by Search Engines outside my preferred countries, then please build on it.
much appreciated

1 Like

Both for the same reason. Huge internet services like Google and advertisement syndicates like Google Ads and similar crawlers make extensive use of cloud services, so you never know from which datacenter their bots will try to fetch your pages, images etc. While it makes sense that they use the datacenter that is the closest to your site, that is not always the case. Several factors, like Internet traffic congestion and legal compliance may make them route their visits through different datacenters at different times. This has no relation to what countries they index your site for. You can set language and region by tagging your HTML and adjusting settings on Google Search Console.

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.