How to block a country in CloudFlare

Jugo Mobile
By
Jugo Mobile
Jugo Mobile is a platform dedicated to high-quality content in gaming, sports, and tech. Engage with high-quality content and connect with fellow enthusiasts and experts. Explore...
8 Min Read

As traffic is the driving force of any website, owners often welcome an increase in the number of visitors. However, these surges can sometimes be caused by hackers and bots. As a website administrator, you can usually trace these attacks to specific countries. If traffic from these countries is not relevant to the operation of your website, blocking them is the best option. This way you will safeguard your website and protect visitors from harm.

If you’re not sure how to do this, you’ve come to the right place. Read on to learn how to block a country using Cloudflare.

Why block a country from your website?

Security is the most common reason for preventing users from visiting your website. Every website is somewhat vulnerable to malicious traffic and security attacks. The most frequent attacks are:

  • XSS attacks, which can compromise the private information of website users.
  • DDoS attacks, which take a website offline temporarily or permanently.
  • Phishing attacks, which can compromise the sensitive information of website users.
  • Injection attacks, which target the server database directly and reveal user input and hidden data.
  • Directory traversal attacks, which can compromise access to the website, databases, and configuration files.

If most of these attacks come from one or more specific countries, blocking them will save you and your website a lot of trouble.

Another reason for geoblocking is having a country-specific website. Let’s say you have an online store that only serves people living in one country. If that’s the case, blocking other countries can protect your server resources from being drained by useless traffic.

Finally, copyright, license terms, and other legal obligations may require blocking certain countries from accessing your website content.

How to know which countries to block

Although conversations about cyberattacks mainly revolve around China and Russia, each website is different. There’s no need to guess as you can quickly check site analytics to determine where threats are coming from.

  1. Login in your Cloudflare account.
    1712433630 441 How to block a country in CloudFlare
  2. Select the domain whose analytics you want to view at the top of your page.
    1712433630 198 How to block a country in CloudFlare
  3. Tap the “Analysis” icon from the list of blue icons at the top of the page.
    1712433630 656 How to block a country in CloudFlare
  4. Go to the “Security” tab.
    1712433630 286 How to block a country in CloudFlare
  5. Navigate to the “Threats by Country” dashboard.
    1712433630 468 How to block a country in CloudFlare

This dashboard is an interactive map that highlights the countries where threats to your website originated. Cloudflare Firewall provides most of the metrics for this tab.

To see where most attacks are coming from, see the “Countries/regions with top threats” data table.

Cloudflare How to block a country

There are several ways to block a country on your website, including using ModSecurity or .htaccess files. However, if you don’t have access to your web server, using Cloudflare Firewall can be helpful.

For this method to work, you must have a Cloudflare account. Additionally, the account must be enabled for the domain for which you want to block traffic. Finally, the geo-blocking feature works best if you’re on Enterprise plan.

Once everything is set up, blocking a country in Cloudflare using the built-in Firewall feature is relatively simple:

  1. Login in your Cloudflare account.
    1712433631 620 How to block a country in CloudFlare
  2. If you own multiple domains, select the domain you want this rule to apply to at the top of the page.
    1712433631 914 How to block a country in CloudFlare
  3. Click the “Security” icon from the list at the top of your page.
    1712433631 708 How to block a country in CloudFlare
  4. Tap the “Firewall Rules” tab.
    1712433631 423 How to block a country in CloudFlare
  5. Press the blue “Create a firewall rule” button.
    1712433631 966 How to block a country in CloudFlare
  6. Enter a descriptive name in the “Rule Name” field, for example, “Block faulty countries.”
    1712433631 17 How to block a country in CloudFlare
  7. Navigate to the “When incoming requests match…” section.
    1712433631 190 How to block a country in CloudFlare
  8. Under “Field,” select “Country.”
    1712433631 676 How to block a country in CloudFlare
  9. Once the remaining fields in the section are no longer grayed out, set the “Operator” field to “is in.”
    1712433631 153 How to block a country in CloudFlare
  10. Tap the “Value” tab to display a list of countries.
    1712433631 676 How to block a country in CloudFlare
  11. Select each country whose access to your website you want to block.
    1712433632 951 How to block a country in CloudFlare
  12. Click the “O” button next to the list of countries.
    1712433632 723 How to block a country in CloudFlare
  13. Go to the “Then…” section.
    1712433632 158 How to block a country in CloudFlare
  14. Under “Choose an action,” select “Block.”
    1712433632 57 How to block a country in CloudFlare
  15. Once you have set up all the countries, press the “Deploy” button.
    1712433632 632 How to block a country in CloudFlare

The Firewall rule has already been created. All traffic from the countries you have selected will be blocked.

However, the established rule is not finite. You can always edit it to add or remove a country. Here’s what you should do:

  1. Navigate to the “Firewall Rules” tab.
    1712433631 423 How to block a country in CloudFlare
  2. Scroll down to the list of rules.
    1712433632 947 How to block a country in CloudFlare
  3. Tap the wrench icon to the right of the rule you want to edit.
    1712433632 6 How to block a country in CloudFlare
  4. Go to the “Value” field in the “When incoming requests match…” section.
    1712433632 643 How to block a country in CloudFlare

To block a new country, tap the “Value” field and select the country from the drop-down list. If you want to unblock a country, simply tap the “x” sign next to its name.

Once you are happy with the updated list, press “Save” in the lower right corner of the screen.

If you want to block traffic from specific countries periodically, you can create a separate rule for them. Then, when you want to unlock the countries, you can disable the button next to the wrench icon. This disables the Firewall rule until you decide to enable it again.

Additionally, you can also delete a rule entirely if you no longer need it. Simply press the “x” button to the far right of the rule names.

How to make sure the firewall is working

If you are not sure whether you have configured the Firewall rule correctly, you can check the Firewall statistics periodically. Here’s what you should do:

  1. Tap the “Security” icon from the list at the top of your page.
    1712433631 708 How to block a country in CloudFlare
  2. Go to the “Overview” tab.
    1712433632 600 How to block a country in CloudFlare
  3. Scroll down to “Activity Log.”
    1712433632 485 How to block a country in CloudFlare

In the “Activity Log”, you can see the following tabs:

  • Date
  • Action taken
  • Country
  • IP adress
  • Service

You can search for the countries you have blocked in the “Country” tab. If you successfully blocked that country, the “Action Taken” tab next to it will show “Block.”

Security First

Protecting a website from malicious bots and hackers is the main reason why administrators consider blocking a country on their website. Whether or not you’re considering geoblocking for the same reason, Cloudflare offers you an easy way to achieve your goals.

The best aspect of using a firewall is knowing that it does not affect your website or its traffic in a detrimental way. It simply blocks requests coming from unwanted countries before they can cause a problem.

Share This Article
Follow:
Jugo Mobile is a platform dedicated to high-quality content in gaming, sports, and tech. Engage with high-quality content and connect with fellow enthusiasts and experts. Explore the latest trends and innovations in our vibrant community. Join us and experience the future today!
Leave a Comment
Grow your brand and reach a larger audience. Advertise with us today and get noticed by thousands.
© 2025 Jugo Mobile. All Rights Reserved.