Setting a Bucket Referer

Last Updated At: 2025-10-21 09:10:00

Description

The PUT Bucket referer API is used to set a Referer allowlist or blocklist for a bucket.

Request

Request Example

PUT /?referer HTTP 1.1
Host: <BucketName-APPID>.<Endpoint>
Date:GMT Date
Authorization: Auth String
Content-Length:length
Content-MD5:MD5

Note:

Authorization: Auth String (See Request Signature for details.)

Request Header

Common Headers

This request uses common request headers. For details, see Public Request Headers.

Non-common Headers

Required Headers

Name Description Type Required
Content-Length Length (bytes) of HTTP request content as defined in RFC 2616. String Yes
Content-MD5 MD5 checksum value of the 128-bit content encoded with Base64 defined in RFC 1864. This header is used to check whether the file content is changed. String Yes

Request Body

The specific node content of the request body of this request is as follows.

<RefererConfiguration>
  <Status>Enabled</Status>
  <RefererType>White-List</RefererType>
  <DomainList>
    <Domain>*.domain1.com</Domain>
    <Domain>*.domain2.com</Domain>
  </DomainList>
  <EmptyReferConfiguration>Allow</EmptyReferConfiguration>
</RefererConfiguration>

The specific contents are described as follows:

Name Parent Node Description Type Required
RefererConfiguration No Anti-hotlinking configuration information Container Yes
Status RefererConfiguration Whether to enable anti-hotlinking, enumeration value: Enabled, Disabled. String Yes
RefererType RefererConfiguration Anti-hotlinking type, enumeration value: Black-List, White-List String Yes
DomainList RefererConfiguration Valid domain name list. Supports multiple domain names (prefix matching). Supports domain names and IP addresses with ports. Supports the wildcard * as a wildcard for second-level domain names or multi-level domain names. Container Yes
Domain DomainList Single valid domain name
For example, www.test.com/example, 192.168.1.2:8080, and *.test.com.
String Yes
EmptyReferConfiguration RefererConfiguration Whether to allow access with a null Referer. Enumeration value: Allow, Deny. The default value is Deny. String No

Response

Response Headers

This API only returns the public response header. For details, see Common Response Headers documentation.

Response Body

The response body is empty.

Error Code

This request has no error. For all errors, see Error Codes documentation.

Practical Case

Request

PUT /?referer HTTP 1.1
Host: <BucketName-APPID>.<Endpoint>
Date: Fri, 25 Feb 2017 04:10:22 GMT
Authorization:q-sign-algorithm=sha1&q-ak=AKIDZfbOAo7cllgPvF9cXFrJD0a1ICvR****&q-sign-time=1547105134;32526689134&q-key-time=1547105134;32620001134&q-header-list=content-md5;content-type;host&q-url-param-list=referer&q-signature=0f7fef5b1d2180deaf6f92fa2ee0cf87ae83f****
Content-MD5: kOz7g54LMJZjxKs070V9jQ==
Content-Type: application/xml

<RefererConfiguration>
  <Status>Enabled</Status>
  <RefererType>White-List</RefererType>
  <DomainList>
    <Domain>*.domain1.com</Domain>
    <Domain>*.domain2.com</Domain>
  </DomainList>
  <EmptyReferConfiguration>Allow</EmptyReferConfiguration>
</RefererConfiguration>

Response

HTTP/1.1 200 OK
Content-Length: 0
Connection: keep-alive
Date: Fri, 25 Feb 2017 04:10:22 GMT
x-cos-request-id: NTg3ZjFjMmJfOWIxZjRlXzZmNDhf****