tencent cloud

Cloud Object Storage

Release Notes and Announcements
Release Notes
Announcements
Product Introduction
Overview
Features
Use Cases
Strengths
Concepts
Regions and Access Endpoints
Specifications and Limits
Service Regions and Service Providers
Billing
Billing Overview
Billing Method
Billable Items
Free Tier
Billing Examples
Viewing and Downloading Bill
Payment Overdue
FAQs
Getting Started
Console
Getting Started with COSBrowser
User Guide
Creating Request
Bucket
Object
Data Management
Batch Operation
Global Acceleration
Monitoring and Alarms
Operations Center
Data Processing
Content Moderation
Smart Toolbox
Data Processing Workflow
Application Integration
User Tools
Tool Overview
Installation and Configuration of Environment
COSBrowser
COSCLI (Beta)
COSCMD
COS Migration
FTP Server
Hadoop
COSDistCp
HDFS TO COS
GooseFS-Lite
Online Tools
Diagnostic Tool
Use Cases
Overview
Access Control and Permission Management
Performance Optimization
Accessing COS with AWS S3 SDK
Data Disaster Recovery and Backup
Domain Name Management Practice
Image Processing
Audio/Video Practices
Workflow
Direct Data Upload
Content Moderation
Data Security
Data Verification
Big Data Practice
COS Cost Optimization Solutions
Using COS in the Third-party Applications
Migration Guide
Migrating Local Data to COS
Migrating Data from Third-Party Cloud Storage Service to COS
Migrating Data from URL to COS
Migrating Data Within COS
Migrating Data Between HDFS and COS
Data Lake Storage
Cloud Native Datalake Storage
Metadata Accelerator
GooseFS
Data Processing
Data Processing Overview
Image Processing
Media Processing
Content Moderation
File Processing Service
File Preview
Troubleshooting
Obtaining RequestId
Slow Upload over Public Network
403 Error for COS Access
Resource Access Error
POST Object Common Exceptions
API Documentation
Introduction
Common Request Headers
Common Response Headers
Error Codes
Request Signature
Action List
Service APIs
Bucket APIs
Object APIs
Batch Operation APIs
Data Processing APIs
Job and Workflow
Content Moderation APIs
Cloud Antivirus API
SDK Documentation
SDK Overview
Preparations
Android SDK
C SDK
C++ SDK
.NET(C#) SDK
Flutter SDK
Go SDK
iOS SDK
Java SDK
JavaScript SDK
Node.js SDK
PHP SDK
Python SDK
React Native SDK
Mini Program SDK
Error Codes
Harmony SDK
Endpoint SDK Quality Optimization
Security and Compliance
Data Disaster Recovery
Data Security
Cloud Access Management
FAQs
Popular Questions
General
Billing
Domain Name Compliance Issues
Bucket Configuration
Domain Names and CDN
Object Operations
Logging and Monitoring
Permission Management
Data Processing
Data Security
Pre-signed URL Issues
SDKs
Tools
APIs
Agreements
Service Level Agreement
Privacy Policy
Data Processing And Security Agreement
Contact Us
Glossary

Setting Hotlink Protection

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-11-28 17:49:13

Overview

Tencent Cloud COS provides hotlink protection to help users avoid unnecessary losses caused by malicious programs' stealing public network traffic using resource URLs or stealing resources. We recommend that you configure the blocklist/allowlist in Hotlink Protection Settings on the console to ensure security protection.
Note:
If a signature is carried in the access URL or headers, hotlink protection−based verification will not be performed.
When configuring hotlink protection, you can add your domain to the allowlist for the multipart upload request of large files.

Directions

1. Log in to the COS console. Click Bucket List on the left sidebar to open the Bucket List page.
2. Locate the bucket for which you want to set hotlink protection, and click its name to enter the bucket management page.
3. Click Security Management > Hotlink Protection, find the hotlink protection configuration item, and click Edit.
4. Switch the status to Enable, select a list type (blocklist or allowlist), input the domain name or IP address to be added to the blocklist or allowlist in the Referer configuration item, confirm and click save, configuration items are described as follows:



Blocklist: Select this item to deny access to the default access address of the bucket for domain names or IP addresses in Referer, and return a 403 error.
Allowlist: Select this item to allow access to the default access address of the bucket for domain names or IP addresses in Referer. Other domains or IPs will be rejected when accessing the default access address of the bucket, and a 403 error will be returned.
Empty referer: For an HTTP request, the header referer can be left empty (i.e., the HTTP request header has no referer field or the referer field is empty).
Referer: Enter up to 30 domain names or IP addresses (one per line). The wildcard * is supported, such as *.test.com. Examples are as follows:
If www.example.com is specified, www.example.com/123, www.example.com.cn, and other addresses with the prefix of www.example.com will also be included in the list.
Domain names and IPs with ports are supported, such as www.example.com:8080 and 10.10.10.10:8080.
If *.example.com is specified, addresses such as a.b.example.com/123 and a.example.com are also included.
Note:
If accelerated access is implemented via a CDN endpoint domain name, CDN hotlink protection rules will be executed before COS hotlink protection rules.

Using REST API/SDK

You can set hotlink protection through the following API:
You can directly call the SDK to set hotlink protection. For details, please refer to the following SDK documentation for different languages:

Example

A user with the APPID of 1250000000 creates a bucket named examplebucket-1250000000 and places an image picture.jpg in the root directory. COS has generated the following default access address according to the rules:
examplebucket-1250000000.file.myqcloud.com/picture.jpg
User A owns a website:
www.example.com
and embeds the image into the homepage index.html.
Webmaster B manages a website:
www.fake.com
and wants to put this image on www.fake.com. But he doesn't want to pay for traffic costs. He creates a direct link to picture.jpg through the following address and places it into the homepage index.html on www.fake.com.
examplebucket-1250000000.file.myqcloud.com/picture.jpg
In such cases, to avoid losses for User A, we provide the following two methods of enabling hotlink protection.

Method 1

Configure the blacklist by entering the domain name *.fake.com, and save.

Method 2

The allowlist method: Add *.example.com to the allowlist and save.
The image is displayed normally when http://www.example.com/index.html is accessed. The image is also displayed normally when http://www.fake.com/index.html is accessed.
The image is displayed normally when http://www.example.com/index.html is accessed. The image cannot be displayed when http://www.fake.com/index.html is accessed.

Notes for Mini Program

1. For network requests using Weixin Mini Programs, the referer value is fixed as https://servicewechat.com/{appid}/{version}/page-frame.html.
2. If hotlink protection is enabled for your bucket, to allow Weixin Mini Programs to load COS images, add servicewechat.com to your hotlink allowlist in the COS console.

Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan