User-Agent blacklists and whitelists

Updated at:

A User-Agent blacklist or whitelist controls access to resources under an accelerated domain name based on the User-Agent field in HTTP request headers. Configure a blacklist to deny specific clients, or configure a whitelist to allow only specific clients.

Blacklist and whitelist types

A User-Agent list has the following types:

  • Blacklist — If the User-Agent field of an HTTP request header matches the blacklist, the user cannot access the requested resource, and a 403 status code is returned.

  • Whitelist — Users can access the resources under the accelerated domain name only if the User-Agent field of the HTTP request header matches the whitelist.

Select the type based on the access control result that you want:

  • To block specific clients, such as IE browsers, and allow all other clients, select Blacklist.

  • To allow only specific clients and block all other clients, select Whitelist.

Usage notes

Before you configure a User-Agent blacklist or whitelist, note the following:

  • The User-Agent blacklists and whitelists feature does not support access control for requests that do not carry a User-Agent header. To control these requests, use the EdgeScript feature instead. For more information, see EdgeScript. Alternatively, submit a requestapply for backend configuration.

  • To perform access control on requests that carry a User-Agent header with an empty value, use ^$ to represent an empty User-Agent value. The ^$ pattern matches only an empty User-Agent value, not requests that do not carry a User-Agent header.

    • Under a whitelist: If a rule contains ^$, requests that carry a User-Agent header with an empty value are allowed.

    • Under a blacklist: If a rule contains ^$, requests that carry a User-Agent header with an empty value are denied.

  • When this feature references rule conditions from the Rules Engine, the execution order follows the priority order of the rule conditions configured in the Rules Engine, not the priority order of this feature's own configuration.

Procedure

  • Log on to the DCDN console.

  • Log on to the DCDN console.

    Log on to the DCDN console.

  • In the left-side navigation pane, click Domain Names.

  • In the left-side navigation pane, click Domain Names.

  • On the Domain Names page, find the target domain name and click Configure.

  • In the left-side navigation tree of the domain name, click Access Control.

    1. Click the User-Agent Blacklist/Whitelist tab.

    2. Turn on the User-Agent Blacklist/Whitelist switch. Follow the on-screen instructions to configure the User-Agent Blacklist or Whitelist.

      Parameter

      Description

      Type

      The type of the User-Agent list. Valid values: Blacklist and Whitelist. For the behavior of each type, see Blacklist and whitelist types.

      Rules

      When you configure User-Agent fields, separate multiple values with vertical bars (|). Wildcards (*) are supported. Example: *curl*|*IE*|*chrome*|*firefox*.

      Note

      For more information about how to match an empty User-Agent value and requests that do not carry a User-Agent header, see Usage notes.

    3. Click OK.

    Examples

    • Example 1: Blacklist

      Rule: *IE*|^$

    Result: When a request comes from an IE browser, or the User-Agent field of the request header carries an empty value, the requested resource cannot be accessed. Requests that do not carry a User-Agent header are not affected by this rule.

    • Example 2: Whitelist

      Rule: *IE*|*firefox*

    Result: Only requests from IE or Firefox browsers can access the requested resource. All other requests are denied.