Configuration. Set values in the User Agents Policy

Set via the control panel
Set via the API

You can set the user agents that you want to allow or deny access to your content in the User Agents Policy. You can configure these values using the control panel or API.

Set via the control panel

To set the user agents using the control panel:

1. Go to CDN and select the CDN resource you want to configure.

image1.png

2. In the navigation panel, under the Access section, select User agents policy.

image2.png

3. Toggle Enable user agents policy and choose either the Allow by default or Block by default option:

  • Selecting Allow by default allows access for all user agents except those specified.
  • Choosing Block by default blocks access for all user agents except those specified.

image3.png

4. Set one or more user agents in the User-Agent select box. Accepted values are:

  • Empty value. This appears as an option in the select box. Select this value to allow or block incoming requests that do not have a User-Agent header.

  • User agent string. Enter one or more unique user agents. The maximum length of each string is 255 characters. If you need to increase this limit, you can contact our support team.

Note: User-Agent text box cannot be left blank.

5. Click Save changes. Allow at least 15 minutes for the changes to take effect.

Set via the API

To set the user agents using the API, the request must include the user_agent_acl object. The following is a sample code for the object:

"options": {
"user_agent_acl": {
"enabled": true,
"policy_type": "allow",
"excepted_values": [
"",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
]
}
}

Request properties

The user_agent_acl object passes the following information:

Property Description
enabled This property indicates whether to enable the User Agents Policy.

Possible values:

  • true enables the option
  • false disables the option
policy_type This property indicates the action to apply to the matching request.

Possible values:

  • allow allows the request
  • deny blocks the request
excepted_values This property is an array of user agents to allow or block. The array must contain at least 1 item.

Possible values:

  • two double quotation marks without a space in-between ("") represents the empty value
  • a string that represents the user agent, with a maximum length of 255 characters; if you need to increase this limit, you can contact our support team

Example

This example shows a CDN update request that activates the User Agents Policy and blocks the requests without a User-Agent header.

image7.png

Was this article helpful?
Recently viewed articles