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
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

Geo-blocking

Updated on 2025-02-28 GMT+08:00

You can prevent users in certain geographical locations from accessing your content.

Scenarios

You can use geo-blocking when your businesses cannot be accessed by users in specific regions due to local laws and regulations or business attributes. CDN identifies client IP addresses to determine the user access source. The working principle is as follows:

  1. Assume that your domain name www.example.com does not serve users in city W, and you have configured a blacklist for city W on the CDN console.
  2. CDN receives a request to access www.example.com from an IP address in city W. The DNS resolves the request to a CDN PoP in city W.
  3. The PoP detects that this IP address is not allowed to download resources under your domain name.
  4. CDN returns HTTP status code 403 (Forbidden) to the user.

Precautions

  • You can configure up to 20 rules.
  • If a blacklist and whitelist are configured for the same resource, when a user in both lists accesses the resource, the blacklist takes effect and status code 403 is returned.
  • If a blacklist and whitelist are configured for the same resource, when a user outside both lists accesses the resource, status code 403 is returned.
  • Huawei Cloud periodically updates the IP address library. The locations of IP addresses that are not in the library cannot be identified. CDN allows requests from such IP addresses and returns resources to the users.
  • If your domain name is connected to EdgeSec and a geo-blocking rule is configured in both services, the rule in CDN is executed first.

Procedure

  1. Log in to Huawei Cloud console. Choose Service List > Content Delivery & Edge Computing > Content Delivery Network.

    The CDN console is displayed.

  2. In the navigation pane, choose Domains.
  3. In the domain list, click the target domain name or click Configure in the Operation column.
  4. Click the Access Control tab.
  5. In the Geo-blocking area, click Add.
    Figure 1 Adding a geo-blocking rule
    Table 1 Parameter details

    Parameter

    Description

    Example

    Rule Type

    • Blacklist: Users in regions specified in the blacklist cannot access resources and status code 403 is returned.
    • Whitelist: Only users in regions specified in the whitelist can access resources. Status code 403 is returned for other users.

    Blacklist

    Content

    • All files: The rule takes effect for all files.
    • Directory: The rule takes effect for resources in the specified directory.
    • Full path: The rule takes effect for resources corresponding to the paths.

    All files

    Rule

    Directory
    • Start with a slash (/) and separate directories by commas (,).
    • Enter up to 100 directories.
    • Do not enter wildcard characters (*).
    Full path
    • Start with a slash (/) or wildcard (*). Wildcards (*) can be used for match.
      • Do not enter two consecutive wildcard characters (*).
      • Enter up to two wildcard characters (*).
    • Enter up to 100 paths and separate them by comma (,).
      NOTE:
      • Each whitelist or blacklist rule must be unique.
      • You can configure only one rule for all files.

    /test/folder01,/test/folder02

    Locations

    User locations to which the rule applies. That is, users in the specified locations cannot access the resources (blacklist) or only they can access the resources (whitelist). For details about the supported regions, see Table 2.

    Chinese mainland

    IP Exceptions

    IP addresses excluded from this rule. For example, if you have configured a blacklist whose Content is All files and added an exception IP address 0.0.0.0, this IP address is not restricted by this blacklist rule and requests from this IP address are accepted.

    • IP addresses and CIDR blocks in the IP address/Subnet mask format are supported.
    • Enter up to 500 IP addresses and CIDR blocks separated by commas (,).
    • Wildcards are not supported, for example, 192.168.0.*.
    • IPv6 is supported.

    0.0.0.0

  6. Configure related information and click OK.

Supported Regions

Table 2 Supported regions

Geographic Region

User Location

Asia

Afghanistan, Armenia, Azerbaijan, Bahrain, Bangladesh, Bhutan, Cambodia, Chinese mainland, Georgia, Hong Kong (China), India, Indonesia, Iraq, Israel, Japan, Jordan, Kazakhstan, Kuwait, Kyrgyzstan, Lao People's Democratic Republic, Lebanon, Macao (China), Malaysia, Maldives, Mongolia, Myanmar, Nepal, Oman, Pakistan, Palestine, Philippines, Qatar, Republic of Korea, Saudi Arabia, Singapore, Sri Lanka, Taiwan (China), Tajikistan, Thailand, Timor-Leste, Türkiye, Turkmenistan, United Arab Emirates, Uzbekistan, Vietnam, and Yemen

Europe

Albania, Andorra, Austria, Belarus, Belgium, Bosnia and Herzegovina, Bulgaria, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Faroe Islands, Finland, France, Greece, Hungary, Iceland, Ireland, Italy, Latvia, Lithuania, Luxembourg, Malta, Monaco, Montenegro, Netherlands, North Macedonia, Norway, Poland, Portugal, Republic of Moldova, Romania, San Marino, Serbia, Slovakia, Slovenia, Spain, Sweden, Switzerland, and United Kingdom of Great Britain and Northern Ireland

South Africa

Algeria, Angola, Benin, Botswana, Burkina Faso, Burundi, Cameroon, Central African Republic, Chad, Comoros, Côte d'Ivoire, Democratic Republic of the Congo, Djibouti, Egypt, Equatorial Guinea, Eritrea, Eswatini, Ethiopia, Gabon, Gambia, Ghana, Guinea, Guinea-Bissau, Kenya, Lesotho, Liberia, Libya, Madagascar, Malawi, Mali, Mauritania, Mauritius, Morocco, Mozambique, Namibia, Niger, Nigeria, Republic of the Congo, Rwanda, Sao Tome and Principe, Senegal, Seychelles, Sierra Leone, Somalia, South Africa, South Sudan, Togo, Tunisia, Uganda, United Republic of Tanzania, Zambia, and Zimbabwe

North America

Antigua and Barbuda, Bahamas, Barbados, Belize, Canada, Costa Rica, Dominica, Dominican Republic, El Salvador, Grenada, Haiti, Honduras, Jamaica, Mexico, Nicaragua, Panama, Saint Kitts and Nevis, Saint Lucia, Saint Vincent and the Grenadines, Trinidad and Tobago, and United States of America

Oceania

Australia, Cook Islands, Fiji, Micronesia, Kiribati, Marshall Islands, Nauru, Niue, New Zealand, Papua New Guinea, Solomon Islands, Tokelau, Tonga, Tuvalu, Vanuatu, and Samoa

South America

Argentina, Bolivia, Brazil, Chile, Colombia, Ecuador, Guyana, Paraguay, Peru, Suriname, and Venezuela

Examples

Example 1: Assume that you have configured the following rules for the domain name www.example.com.

Result:

  • The blacklist takes precedence over the whitelist. Therefore, the blacklist takes effect. When a user in the Chinese mainland accesses a resource in the /test folder (for example, www.example.com/test/abc.jpg), status code 403 is returned.
  • When a user in Hong Kong (China) accesses the same resource, neither the blacklist nor the whitelist is hit. In this case, the access is denied and status code 403 is returned.

Example 2: Assume that you have configured the following rules for the domain name www.example.com.

Result:

  • When a user in Hong Kong (China) accesses a resource in the /test folder (for example, www.example.com/test/abc.jpg), the blacklist is hit and status code 403 is returned.
  • When a user in the Chinese mainland accesses the same resource, the whitelist is hit and the resource is returned to the user.
  • When a user in Macao (China) accesses the same resource, neither the blacklist nor the whitelist is hit. In this case, the access is denied by default and status code 403 is returned.

Example 3: Assume that you have configured the following rules for the domain name www.example.com.

Result:

  • When a user in Hong Kong (China) accesses a resource in the /test/abc folder (for example, www.example.com/test/abc/1.jpg), the blacklist is hit and status code 403 is returned.
  • When a user in the Chinese mainland accesses a resource in the /test folder (for example, www.example.com/test/cat.jpg), the whitelist is hit and the corresponding resource is returned to the user.
  • When a user in Hong Kong (China) accesses a resource in the /test folder (for example, www.example.com/test/cat.jpg), neither the blacklist nor the whitelist is hit. In this case, the access is denied by default and status code 403 is returned.
  • When a user in Macao (China) accesses a resource in the /test folder (for example, www.example.com/test/cat.jpg), neither the blacklist nor the whitelist is hit. In this case, the access is denied by default and status code 403 is returned.

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