All Products
Search
Document Center

Web Application Firewall:Configure custom response pages

Last Updated:Mar 31, 2026

When WAF blocks a request, it returns a default block page to the client. The custom response module lets you replace that page with your own content — including a custom HTTP status code, response headers, and response body in HTML or JSON. This topic describes how to create a protection template and configure the block page content.

By default, the custom response module is disabled.

Default block page

Without a custom response rule in place, WAF returns the following default block page:

Default WAF block page

Once you configure a protection rule, WAF replaces the default page with your custom Status Code, Response Headers, and Response Body for all protected objects the template is applied to.

Prerequisites

Before you begin, ensure that you have:

Template types

The custom response module uses two types of protection templates:

Template typeWho creates itApplies to
Default protection templateYou create it manually. WAF does not provide one initially.Automatically applied to all protected objects and object groups not associated with a custom protection template, including newly added ones. Manually adjustable.
Custom protection templateYou create it manually.Only the protected objects and object groups you specify in Apply To.

Key constraints:

  • Each protection module supports only one default protection template.

  • The default template can only be set at template creation time and cannot be changed later.

  • Each protected object or object group can be associated with only one custom response protection template.

Create a protection template

The custom response module does not include an initial default template. Create one before enabling any protection rule.

  1. Log on to the WAF 3.0 console. In the top navigation bar, select the resource group and region of your WAF instance. Select Chinese Mainland or Outside Chinese Mainland.

  2. In the left-side navigation pane, choose Protection Configuration > Core Web Protection.

  3. On the Core Web Protection page, scroll to the Custom Response section and click Create Template.

  4. In the Create Template - Custom Response panel, configure the following parameters and click OK.

    ParameterDescription
    Template NameEnter a name for the template. The name must be 1–255 characters and can contain letters, digits, periods (.), underscores (_), and hyphens (-).
    Save As Default TemplateSelect this option to make the template the default. The default template is automatically applied to all protected objects and object groups that are not associated with a custom protection template, including newly added ones. You can set only one default template per protection module, and the setting cannot be changed after creation.
    Rule ConfigurationConfigure the block page content. Each custom response template contains exactly one protection rule. See Rule configuration parameters.
    Apply ToSelect the protected objects and object groups on the Protected Objects and Protected Object Groups tabs. If you set a default template, all unassociated objects are selected automatically. If you do not set a default template, no objects are selected automatically. For more information, see Configure protected objects and protected object groups.

Rule configuration parameters

ParameterDescription
Status CodeThe HTTP status code WAF returns to the client when a request is blocked. Valid values: 200–600. Default value: 405.
Custom HeaderResponse header fields returned to the client when a request is blocked. Each field has a Header Name and Header Value. Add up to five fields. To specify the format of the response body, add a Content-Type header field (for example, text/html for an HTML body or application/json for a JSON body).
Response BodyThe source code of the block page. The content must be in HTML or JSON format, and the maximum length is 4,000 characters. To include the request ID on the block page so you can look up blocked requests in Simple Log Service, add {::trace_id::} at the appropriate location in the response body.
Important

After a protection template takes effect, it replaces the default block page for all protected objects it applies to. To revert to the default block page, disable or delete the protection template.

Newly created templates are enabled by default. After creation, the template appears in the template list where you can:

  • View the number of protected objects and object groups associated with the template in the Protected Object/Group column.

  • Toggle the switch in the Status column to enable or disable the template.

  • Click Create Rule in the Actions column to add a protection rule to the template.

  • Click Edit, Delete, or Copy in the Actions column to manage the template.

  • Click the Expand icon icon to the left of the template name to view its protection rules.

Next steps