Skip to content

Commit e2f5ff6

Browse files
Merge pull request #304621 from halkazwini/waf-custom
Custom response code and body
2 parents 4b5abab + 8f5755e commit e2f5ff6

4 files changed

Lines changed: 41 additions & 0 deletions

File tree

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

articles/web-application-firewall/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ items:
108108
href: geomatch-custom-rules-examples.md
109109
- name: Request size limits
110110
href: ./ag/application-gateway-waf-request-size-limits.md
111+
- name: Configure custom response code and body
112+
href: ./ag/configure-custom-response-code.md
111113
- name: WAF engine
112114
href: ./ag/waf-engine.md
113115
- name: Front Door

0 commit comments

Comments
 (0)