Updated on 2024-05-16 GMT+08:00

Configuring a Referer List

Function

This API is used to configure a referer list. Users are identified and filtered based on the list, so access sources can be controlled.

URI

PUT /v1.0/cdn/domains/{domain_id}/referer

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

domain_id

Yes

String

Specifies the acceleration domain name ID. For details, see Querying Details About a Domain Name.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Enterprise project that the domain name to be modified belongs to. This parameter is valid only when the enterprise project function is enabled. The value all indicates all projects. This parameter is mandatory when you use an IAM user to call this API.

Obtain the enterprise project ID by calling the ListEnterpriseProject API of Enterprise Project Management Service (EPS).

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token.

The token can be obtained by calling the IAM API used to obtain a user token. The value of **X-Subject-Token** in the response header is the user token.
Table 4 Request body parameters

Parameter

Mandatory

Type

Description

referer

Yes

Referer object

Specifies the referer settings.

Table 5 Referer

Parameter

Mandatory

Type

Description

referer_type

Yes

Integer

Specifies the type of the referer filtering rule. Possible values: 0 (no referer filtering), 1 (blacklist), and 2 (whitelist). Default value: 0.

referer_list

No

String

Specifies the referer validation configuration. Multiple IP addresses or domain names are supported and they must be separated by semicolons (;). This parameter is mandatory when referer validation is enabled.

include_empty

No

Boolean

Specifies whether a blank referer is included in the blacklist or whitelist. If you configure a referer blacklist and enable this function, requests with no referers are not allowed. If you configure a referer whitelist and enable this function, requests with no referers are allowed. Default value: false.

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

referer

RefererRsp object

Specifies the referer settings.

Table 7 RefererRsp

Parameter

Type

Description

referer_type

Integer

Specifies the type of the referer filtering rule. Possible values: 0 (no referer filtering), 1 (blacklist), and 2 (whitelist). Default value: 0.

referer_list

String

Specifies the referer validation configuration. Multiple IP addresses or domain names are supported and they must be separated by semicolons (;). This parameter is mandatory when referer validation is enabled.

include_empty

Boolean

Specifies whether a blank referer is included in the blacklist or whitelist. If you configure a referer blacklist and enable this function, requests with no referers are not allowed. If you configure a referer whitelist and enable this function, requests with no referers are allowed. By default, blank referers are not included.

Example Requests

PUT https://cdn.myhuaweicloud.com/v1.0/cdn/domains/ff8080**********************d71/referer?enterprise_project_id=0

{
  "referer" : {
    "referer_type" : 1,
    "referer_list" : "www.example1.com;www.example2.com",
    "include_empty" : false
  }
}

Example Responses

Status code: 200

OK

{
  "referer" : {
    "referer_type" : 1,
    "referer_list" : "www.example1.com;www.example2.com",
    "include_empty" : false
  }
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.