All Products
Search
Document Center

Web Application Firewall:Configure a custom protection policy

Last Updated:Mar 31, 2026

Custom protection policies let you define precise traffic rules for your website — blocking unwanted requests, throttling high-frequency traffic, or monitoring suspicious patterns without blocking.

Rule types

Custom protection policies consist of two rule types:

  • Access control list (ACL) rule — Filters requests based on match conditions such as client IP addresses, request URLs, and request headers. WAF evaluates each request against the conditions and performs the configured action when all conditions are met.

  • HTTP flood protection rule — Combines match conditions with rate limiting. WAF starts counting requests only when match conditions are met, then applies the action when the request rate exceeds your threshold. Use this rule type for hotlink protection, website backend protection, and brute-force prevention.

The rule type is set automatically: disable rate limiting to create an ACL rule, enable it to create an HTTP flood protection rule.

Limitations

The following specifications apply to subscription WAF instances.

SpecificationPro editionBusiness editionEnterprise edition and higher
Custom rules per domain200200200
Advanced match fields (beyond IP and URL)Not supportedSupportedSupported
Rate limitingNot supportedSupportedSupported
Custom statistical objectsNot supportedSupportedSupported

Prerequisites

Before you begin, ensure that you have:

  • A WAF instance

  • Your website added to WAF (see Tutorial)

Create a custom rule

  1. Log on to the WAF console.

  2. In the top navigation bar, select the resource group and the region where your WAF instance is deployed. Select Chinese Mainland or Outside Chinese Mainland.

  3. In the left-side navigation pane, choose Protection Configurations > Website Protection.

  4. At the top of the Website Protection page, select your domain name from the Switch Domain Name drop-down list.

    切换域名

  5. Click the Access Control/Throttling tab, find the Custom Protection Policy section, turn on Status, and click Settings.

    Note

    When custom protection policy is enabled, all requests to your website are checked. To exempt specific requests from inspection, configure a whitelist rule for Access Control/Throttling. For more information, see Configure a whitelist for Access Control/Throttling.

    Custom Protection Policy

  6. On the Custom Protection Policy page, click Create Custom Protection Policy.

  7. In the Add Rule dialog box, configure the rule parameters.

    ParameterDescription
    Rule nameA name for the rule.
    Matching ConditionThe conditions that trigger the rule. Click Add rule to add conditions — up to five. All conditions must be met for the rule to trigger. For supported fields, see Fields in match conditions.
    Rate LimitingToggle to enable rate limiting and convert this rule to an HTTP flood protection rule. When enabled, configure the rate limiting parameters described below.
    ActionThe action WAF performs when the rule is triggered. See Actions below.
    TTL (Seconds)How long the action remains in effect after rate limiting is triggered. Required when rate limiting is enabled.
    Protection TypeSet automatically based on rate limiting status: ACL (rate limiting off) or HTTP Flood Protection (rate limiting on).

    ACL

  8. If you enabled rate limiting, configure the rate limiting parameters.

    ParameterDescription
    Statistical ObjectThe attribute WAF uses to group and count requests. See Statistical objects below.
    Interval (Seconds)The time window during which requests are counted.
    Threshold (Occurrences)The maximum number of requests allowed from the statistical object within the interval. Exceeding this triggers the action.
    Status CodeCounts the number or percentage of a specific HTTP status code within the interval, instead of counting all requests. Select Amount for a count limit, or Percentage (%) for a ratio limit.
    Take Effect ForWhich requests are counted: Feature Matching Objects counts only requests that meet the match conditions; Applied Domains counts all requests to the domain.

    HTTP Flood Protection

  9. Click Save.

    Important

    The rule is enabled immediately after you save it. Verify your match conditions and action before saving to avoid unintended traffic impact.

After creating a rule, you can view, enable, disable, modify, or delete it from the rule list.

Actions

ActionBehavior
MonitorTriggers alerts but does not block requests. Use this to evaluate a new rule before enforcing it.
BlockBlocks the request.
CAPTCHARedirects the request to a CAPTCHA verification page.
Strict CaptchaRedirects the request to a stricter slider CAPTCHA verification page.
JavaScript ValidationPerforms JavaScript validation on the request.
Note

CAPTCHA and JavaScript Validation apply to static pages only. For async requests (XMLHttpRequest or Fetch), enable these validations in the bot management module instead. For more information, see Configure anti-crawler rules for websites.

Note

When rate limiting is enabled, latency may occur in rate calculations. WAF aggregates request data across multiple servers in the cluster, which can introduce a short delay before an action takes effect.

Statistical objects

The statistical object determines how WAF identifies and groups requests for rate counting. Choose based on your use case.

Statistical objectWhat WAF countsWhen to use
IPRequests from the same IP address.General rate limiting when clients connect directly without proxies.
SessionRequests from the same session.Limiting per-user activity without relying on IP addresses.
Custom-HeaderRequests that share the same value in a specified request header.Tracking requests by a user ID, API key, or other custom header.
Custom-ParamRequests that share the same value in a specified query parameter.Tracking requests by a specific URL parameter value.
Custom-CookieRequests that share the same value in a specified cookie.Tracking requests by a session token or user identifier in a cookie.

Custom-Header, Custom-Param, and Custom-Cookie are available on Business edition and higher.

Typical use cases

The following examples show how to combine match conditions and rate limiting parameters for common protection scenarios.

Hotlink protection

Block external sites from embedding your images or media files.

ParameterConfiguration
Matching ConditionHTTP Referer does not contain your domain name
Rate LimitingOff
ActionBlock
Protection TypeACL

Website backend protection

Restrict access to admin paths to authorized IP addresses only.

ParameterConfiguration
Matching ConditionURL starts with /admin
Rate LimitingOff
ActionBlock (combine with an IP whitelist rule to allow admin IPs)
Protection TypeACL

Login endpoint brute-force prevention

Limit the number of login attempts per IP address within a time window.

ParameterConfiguration
Matching ConditionURL equals /login and Method equals POST
Rate LimitingOn
Statistical ObjectIP
Interval (Seconds)60
Threshold (Occurrences)10
ActionBlock
TTL (Seconds)600

What's next

Configure monitoring and alerting for your custom rules using CloudMonitor and Log Service. When traffic matches a custom rule, you receive alert notifications so you can respond quickly. For more information, see Configure WAF alerting.

Related topics: