COS allows you to configure hotlink protection for your bucket. You can set a blocklist and allowlist for access sources to prevent resource hotlinking. This document describes how to configure hotlink protection for a bucket.
Hotlink protection works by checking the Referer address in the request header:
https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/1.jpg
directly in a browser, the request header will not have a Referer.For example, in the figure below, the image 1.jpg
is embedded in https://127.0.0.1/test/test.html
, and a Referer pointing to the access origin will be carried when you access https://127.0.0.1/test/test.html
:
User A uploaded the image resource 1.jpg
to COS, and the accessible link to the image is https://examplebucket-1250000000.cos.ap-guangzhou.myqcloud.com/1.jpg
.
https://example.com/index.html
and the image is accessible.https://b.com/test/test.html
, and user B's webpage can also display the image properly.1.jpg
was hotlinked by user B. User A doesn't know that their resource in COS is being used by user B's webpage and suffers from losses caused by extra traffic fees. In the above Hotlink Protection Case Study, user A can prevent user B from hotlinking their image by setting hotlink protection in the following way:
*.b.com
, and save it.*.example.com
for the domain name, and save.https://example.com/index.html
is accessed.https://b.com/test/test.html
is accessed, as shown below:*
are supported formats (one address per line). Below are configuration rule description and examples:example.com:8080
and 10.10.10.10:8080
.example.com
is configured, addresses prefixed with example.com
can be hit, such as example.com/123
.example.com
is configured, addresses prefixed with https://example.com
and http://example.com
can be hit.example.com
is configured, the domain name with a specific port can also be hit, such as example.com:8080
. example.com:8080
is configured, the domain name example.com
cannot be hit.*.example.com
is configured, its second-level and third-level domain names can be restricted, such as example.com
, b.example.com
, and a.b.example.com
.
Note:After hotlink protection is enabled, the corresponding domain names must be entered.
For questions about hotlink protection, see the Data Security section in COS FAQs.
Apakah halaman ini membantu?