Skip to content

Commit 307d2f1

Browse files
committed
Merge branch 'patch-1' of https://github.com/YaakobiEden/azure-docs-pr into waf-custom
2 parents d8bbc34 + ebacf27 commit 307d2f1

4 files changed

Lines changed: 44 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: Configure custom responses for Azure Web Application Firewall with Application Gateway
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: 03/11/2025
9+
---
10+
11+
12+
# Configure custom response code and body for Azure Application Gateway WAF
13+
14+
15+
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.
16+
17+
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) and PowerShell.
18+
19+
## Configure a custom response status code and message
20+
21+
To customize the response status code and body, take the following steps:
22+
23+
1. Go to your Application Gateway WAF policy in the Azure portal.
24+
25+
1. Under **Settings**, select **Policy settings**.
26+
27+
1. Enter the custom response status code and response body in **Block response status code** and **Block response body** respectively.
28+
29+
30+
31+
:::image type="content" source="../media/application-gateway-waf-configure-custom-response-code-and-body/ag-waf-custom-response-settings.png" alt-text="Screenshot that shows Azure Web Application Firewall Policy settings." lightbox="../media/application-gateway-waf-configure-custom-response-code-and-body/ag-waf-custom-response-settings.png":::
32+
33+
4. Select **Save**.
34+
35+
In this example, we changed the default 403 response code to 429 and set a brief message stating, "The request has been blocked".
36+
37+
:::image type="content" source="../media/application-gateway-waf-configure-custom-response-code-and-body/ag-waf-custom-response.png" alt-text="Screenshot that shows a custom response example.":::
38+
39+
40+
## Next steps
41+
42+
Learn more about [Azure Web Application Firewall on Application Gateway](../ag/ag-overview.md).
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/waf-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)