Edit

Share via


Configure custom response code and body for Azure Application Gateway WAF

By default, when Azure Web Application Firewall (WAF) on Azure Application Gateway blocks a request due to a matched rule, it returns a 403 status code with the message "The request is blocked." You can customize the response by configuring a custom status code and message to better suit your use case.

This article shows you how to configure a custom response page when Azure Application Gateway's Web Application Firewall (WAF) blocks a request using the Azure portal. You can also configure custom responses using the Azure CLI or PowerShell.

Configure a custom response status code and message

To customize the response status code and body, take the following steps:

  1. Go to your Application Gateway WAF policy in the Azure portal.

  2. Under Settings, select Policy settings.

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

    Screenshot that shows Azure Web Application Firewall policy settings.

  4. Select Save.

In this example, we changed the default 403 response code to 429 and set a brief message stating, The request has been blocked.

Screenshot that shows a custom response example.