Configures a Referer whitelist or blacklist to prevent hotlinking attacks.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes SetRefererConfig

The operation that you want to perform. Set the value to SetRefererConfig.

DomainName String Yes example.com

The accelerated domain names. You can specify multiple domain names and separate them with commas (,).

ReferType String Yes block

The type of the Referer list. Valid values:

  • block: blacklist
  • allow: whitelist
DisableAst String No off

Specifies whether to use exact match or fuzzy match. Valid values:

  • on: exact match.
  • off (default): fuzzy match. This match mode automatically searches for domain names that match the specified wildcard domain name.
AllowEmpty String No on

Specifies whether empty Referer headers are allowed. Valid values:

  • on (default): allow
  • off: does not allow
ReferList String No example.org,example.net

The header values that you want to add to the Referer list. Separate values with commas (,).

Response parameters

Parameter Type Example Description
RequestId String 16A96B9A-F203-4EC5-8E43-CB92E68F4CD8

The ID of the request.

Examples

Sample requests

http://cdn.aliyuncs.com/?Action=SetRefererConfig
&DomainName=example.com
&ReferList=example.org,example.net
&ReferType=allow
&AllowEmpty=on
&<Common request parameters>

Sample success responses

XML format

<SetRefererConfigResponse>
      <RequestId>AED00EC1-32A8-4D48-BEB9-BD782AF3C6BD</RequestId>
</SetRefererConfigResponse>

JSON format

{
    "RequestId": "04F0F334-1335-436C-A1D7-6C044FE73368"
}

Error codes

HttpCode Error code Error message Description
400 InvalidReferType.ValueNotSupported The specified value of parameter ReferType is not supported. The error message returned because the ReferType parameter is set to an invalid value. Valid values are block (blacklist) and allow (whitelist).
400 InvalidAllowEmpty.ValueNotSupported The specified value of parameter AllowEmpty is not supported. The error message returned because the AllowEmpty parameter is set to an invalid value.
400 InvalidReferList.Malformed The specified value of parameter ReferList is malformed. The error message returned because the ReferList parameter is set to an invalid list. The format is invalid.
400 InvalidDisableAst.ValueNotSupported The specified value of parameter DisableAst is not supported. The error message returned because the DisableAst parameter is not supported.

For a list of error codes, visit the API Error Center.