How to block a specific country to access my server and my website Print

  • 1

English

This guide explains how to use Cloudflare to filter traffic from a specific country. This is useful for monitoring or blocking traffic from certain geographic regions.

Prerequisites

  • Access to your Cloudflare account.
  • A properly configured domain in Cloudflare.

Steps to filter traffic from a country

1. Log in to Cloudflare

  1. Go to Cloudflare Dashboard.
  2. Log in with your credentials.
  3. Select the domain you wish to configure.

2. Navigate to Firewall Rules

  1. In the side panel, click Security > WAF (Web Application Firewall).
  2. Select Firewall Rules.

3. Create a new rule

  1. Click Create a Firewall Rule.
  2. Assign a name to the rule, such as: Filter Country - Italy.

4. Configure rule criteria

  1. In the Field section, select Country.
  2. In the adjacent column, choose the operator:
    • is: to include only traffic from the specified country.
    • is not: to exclude traffic from the specified country.
  3. In the next field, select the desired country (e.g., Italy).

5. Set the action

Choose the desired action:

  • Allow: Allows traffic only from the specified country.
  • Block: Blocks all traffic from the specified country.
  • Challenge (Captcha): Requires users to complete a CAPTCHA.
  • JS Challenge: Verifies traffic with a JavaScript challenge.

6. Save and apply the rule

  1. Click Deploy to activate the rule.
  2. The rule will be immediately applied and visible in the Firewall Rules list.

Configuration example

Block traffic from Italy

  • Field: Country
  • Operator: is
  • Value: Italy
  • Action: Block

Monitoring and management

  1. Go to Security > Events to view events associated with the rule.
  2. Verify that the filter works as expected.
  3. Edit or disable the rule if necessary.

Additional notes

  • Firewall rules do not affect internal Cloudflare traffic (e.g., API or administrators).
  • Use rules cautiously to avoid blocking legitimate users.

If you need further assistance, contact Utixo technical support.


Was this answer helpful?

« Back