|
| 1 | +--- |
| 2 | +title: Configure custom responses for Azure Application Gateway |
| 3 | +titleSuffix: Azure Web Application Firewall |
| 4 | +description: Learn how to configure a custom response code and body (message) when Azure Web Application Firewall on Azure Application Gateway blocks a request. |
| 5 | +author: YaakobiEden |
| 6 | +ms.author: edenyaakobi |
| 7 | +ms.service: azure-web-application-firewall |
| 8 | +ms.topic: how-to |
| 9 | +ms.date: 08/24/2025 |
| 10 | +--- |
| 11 | + |
| 12 | +# Configure custom response code and body for Azure Application Gateway WAF |
| 13 | + |
| 14 | +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. |
| 15 | + |
| 16 | +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](/cli/azure/network/application-gateway/waf-policy/policy-setting) or PowerShell. |
| 17 | + |
| 18 | +## Configure a custom response status code and message |
| 19 | + |
| 20 | +To customize the response status code and body, take the following steps: |
| 21 | + |
| 22 | +1. Go to your Application Gateway WAF policy in the Azure portal. |
| 23 | + |
| 24 | +1. Under **Settings**, select **Policy settings**. |
| 25 | + |
| 26 | +1. Enter the custom response status code and response body in **Block response status code** and **Block response body** respectively. |
| 27 | + |
| 28 | + :::image type="content" source="../media/configure-custom-response-code/application-gateway-custom-response-settings.png" alt-text="Screenshot that shows Azure Web Application Firewall policy settings." lightbox="../media/configure-custom-response-code/application-gateway-custom-response-settings.png"::: |
| 29 | + |
| 30 | +1. Select **Save**. |
| 31 | + |
| 32 | +In this example, we changed the default 403 response code to 429 and set a brief message stating, *The request has been blocked*. |
| 33 | + |
| 34 | +:::image type="content" source="../media/configure-custom-response-code/application-gateway-custom-response.png" alt-text="Screenshot that shows a custom response example."::: |
| 35 | + |
| 36 | +## Related content |
| 37 | + |
| 38 | +- [Azure Web Application Firewall policy](policy-overview.md) |
| 39 | +- [Create Web Application Firewall policies for Application Gateway](create-waf-policy-ag.md) |
| 40 | +- [Azure Web Application Firewall on Application Gateway](ag-overview.md) |
0 commit comments