Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Web Application Firewall/ User Guide/ Configuring Protection Policies/ Configuring Geolocation Access Control Rules to Block or Allow Requests from Specific Locations

Configuring Geolocation Access Control Rules to Block or Allow Requests from Specific Locations

Updated on 2025-01-17 GMT+08:00

WAF can identify where a request originates. You can set geolocation access control rules in just a few clicks and let WAF block or allow requests from a certain region. A geolocation access control rule allows you to allow or block requests from IP addresses from specified countries or regions.

To allow only the IP addresses in a certain region to access the protected website, configure a rule by referring to Configuration Example - Allowing Access Requests from IP Addresses in a Specified Region.

NOTE:

If you have enabled enterprise projects, ensure that you have all operation permissions for the project where your WAF instance locates. Then, you can select the project from the Enterprise Project drop-down list and configure protection policies for the domain names in the project.

Prerequisites

Constraints

  • This function is not supported in the standard edition.
  • If you are using dedicated WAF instances, upgrade them to the latest version and add IPv6 addresses for IP Address Range, or the settings cannot work.
  • When you add a website through Cloud Mode - Load balancer and set Frontend Protocol of the listener of your ELB load balancer to TCP, UDP, or QUIC, this type of rule does not take effect.
  • One region can be configured in only one geolocation access control rule. For example, if you have blocked requests from Shanghai with a geolocation access control rule, then Shanghai cannot be added to other geolocation access control rules.
  • It takes several minutes for a new rule to take effect. After the rule takes effect, protection events triggered by the rule will be displayed on the Events page.

Configuring a Geolocation Access Control Rule

  1. Log in to the management console.
  2. Click in the upper left corner of the management console and select a region or project.
  3. Click in the upper left corner and choose Web Application Firewall under Security & Compliance.
  4. In the navigation pane on the left, choose Policies.
  5. Click the name of the target policy to go to the protection configuration page.
  6. Click the Geolocation Access Control configuration area and toggle it on or off if needed.

    • : enabled.
    • : disabled.

  7. In the upper left corner above the Geolocation Access Control list, click Add Rule.
  8. In the displayed dialog box, add a geolocation access control rule by referring to Table 1.

    Figure 1 Adding a geolocation access control rule
    Table 1 Rule parameters

    Parameter

    Description

    Example Value

    Rule Name

    Rule name you configured

    -

    Rule Description

    A brief description of the rule. This parameter is optional.

    waf

    Geolocation

    Geographical scope of the IP address. You can select a region inside China or outside China.

    -

    IP Address Range

    • IPv4
    • IPv6
    • Any (IPv4 or IPv6 address)
    NOTE:

    If you are using dedicated WAF instances, upgrade them to the latest version and add IPv6 addresses for IP Address Range, or the settings cannot work.

    IPv4

    Protective Action

    Action WAF will take if the rule is hit. You can select Block, Allow, or Log only.

    Block

  9. Click OK. You can then view the added rule in the list of the geolocation access control rules.

    • To disable a rule, click Disable in the Operation column of the rule. The default Rule Status is Enabled.
    • To modify a rule, click Modify in the row containing the rule.
    • To delete a rule, click Delete in the row containing the rule.

Configuration Example - Allowing Access Requests from IP Addresses in a Specified Region

Assume that domain name www.example.com has been connected to WAF and you want to allow only IP addresses in Shanghai, China to access the domain name. Perform the following steps:

  1. Add a geolocation access control rule: Select Shanghai for Geolocation and select Allow for Protective Action.

    Figure 2 Selecting Allow for Protective Action

  2. Enable geolocation access control.

    Figure 3 Geolocation Access Control configuration area

  3. Configure a precise protection rule to block all requests.

    Figure 4 Blocking all access requests

    For details, see Configuring Custom Precise Protection Rules.

  4. Clear the browser cache and access http://www.example.com.

    When an access request from IP addresses outside Shanghai accesses the page, WAF blocks the access request.

    Figure 5 Block page

  5. Go to the WAF console. In the navigation pane on the left, choose Events. View the event on the Events page. You will see that all requests not from Shanghai have been blocked.

Configuration Example - Blocking Access Requests from IP Addresses in a Specified Region

Assume that domain name www.example.com has been connected to WAF and you want to block all IP addresses from Beijing to access the domain name. The following shows how to configure a rule to this end:

  1. Add a geolocation access control rule, select Beijing for Geolocation and Block for Protective Action.

    Figure 6 Blocking access requests from a specific region

  2. Enable geolocation access control.

    Figure 7 Geolocation Access Control configuration area

  3. Clear the browser cache and access http://www.example.com.

    When an access request from IP addresses inside Beijing accesses the page, WAF blocks the access request.

    Figure 8 Block page

  4. Go to the WAF console. In the navigation pane on the left, choose Events. View the event on the Events page.

    Figure 9 Viewing events - blocking access requests from IP addresses in a region

Protection Effect

To verify WAF is protecting your website (www.example.com) against a rule:

  1. Clear the browser cache and enter the domain name in the address bar to check whether the website is accessible.

    • If the website is inaccessible, connect the website domain name to WAF by referring to Website Settings.
    • If the website is accessible, go to 2.

  2. Add a geolocation access control rule by referring to Configuring a Geolocation Access Control Rule.
  3. Clear the browser cache and access http://www.example.com. Normally, WAF blocks such requests and returns the block page.
  4. Return to the WAF console. In the navigation pane, click Events. On the displayed page, view the event log.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback