How to Block All Traffic Except Spain and Portugal, Allowing Bots

What is the name of the domain?

editora-europa.com

What is the issue you’re encountering

Bots blocked

What steps have you taken to resolve the issue?

Hi everyone,

I’m looking for help in creating a custom rule on Cloudflare to block all traffic coming from countries outside of Spain and Portugal. However, I want to ensure that all bots recognized by Cloudflare (e.g., Googlebot) are allowed through, regardless of the country they originate from.

Here’s what I’d like the rule to achieve:

Allow traffic from Spain (ES) and Portugal (PT).
Allow bots from any location.
Block all other traffic.
I’ve tried experimenting with ip.geoip.country and cf.client.bot, but I’m not sure how to structure the rule properly. Any advice on the correct logic or syntax for a Firewall Rule to achieve this would be greatly appreciated!

Thanks in advance for your guidance!

What is the current SSL/TLS setting?

Full (strict)

Hi there,

The simplest way to do this in my opinion is to create 2 rules:
1st:

2nd:

*Don’t forget to place the “Skip” rule above the block rule, this way known bots will simply skip the block rule.

Take care.

Thank you

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