Edit

Share via


Configure a custom response for Azure Web Application Firewall

By default, when Azure Front Door Web Application Firewall (WAF) blocks a request because of a matched rule, it returns a 403 status code with the message "The request is blocked." The default message also includes the tracking reference string that's used to link to log entries for the request.

In this article, you learn how to configure a custom response status code and a custom message with a reference string for your use case using the Azure portal, PowerShell, or the Azure CLI.

Prerequisites

Configure a custom response status code and message

To customize the response status code and body, follow these steps:

  1. Go to your Front Door WAF policy in the Azure portal.

  2. Under Settings, select Policy settings.

  3. Enter the custom response status code and response body in the Block response status code and Block response body boxes, respectively.

    Screenshot that shows Azure Web Application Firewall Policy settings.

    Note

    The JavaScript challenge and CAPTCHA features are available only in WAF policies on the Azure Front Door Premium tier.

  4. Select Save.

In the previous example, the response code was kept as 403 with a custom message: "Please contact us with this information:".

Screenshot that shows a custom response example.

Note

{{azure-ref}} inserts the unique reference string in the response body. The value matches the TrackingReference field in the FrontDoorAccessLog and FrontDoorWebApplicationFirewallLog logs.

Important

If you leave the block response body blank, the WAF returns a 403 Forbidden response for normal WAF blocks and a 429 Too many requests for rate limit blocks.

Next step