You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/application-gateway/add-http-header-rewrite-rule-powershell.md
+66-30Lines changed: 66 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,51 +5,68 @@ services: application-gateway
5
5
author: mbender-ms
6
6
ms.service: azure-application-gateway
7
7
ms.topic: how-to
8
-
ms.date: 04/12/2019
8
+
ms.date: 07/09/2025
9
9
ms.author: mbender
10
10
ms.custom: devx-track-azurepowershell
11
11
# Customer intent: "As a cloud administrator, I want to configure HTTP header rewrites using Azure PowerShell, so that I can efficiently modify headers in requests and responses for my Application Gateway."
12
12
---
13
13
# Rewrite HTTP request and response headers with Azure Application Gateway - Azure PowerShell
14
14
15
-
This article describes how to use Azure PowerShell to configure an [Application Gateway v2 SKU](./application-gateway-autoscaling-zone-redundant.md) instance to rewrite the HTTP headers in requests and responses.
15
+
This article describes how to use Azure PowerShell to configure an [Application Gateway v2 SKU](./application-gateway-autoscaling-zone-redundant.md) instance to rewrite HTTP headers in requests and responses. Header rewriting enables you to add, remove, or update HTTP headers while the request and response packets move between the client and backend pools.
16
16
17
17
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
18
18
19
-
## Before you begin
19
+
## Prerequisites
20
20
21
-
- You need to run Azure PowerShell locally to complete the steps in this article. You also need to have Az module version 1.0.0 or later installed. Run `Import-Module Az` and then `Get-Module Az` to determine the version that you have installed. If you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-azure-powershell). After you verify the PowerShell version, run `Login-AzAccount` to create a connection with Azure.
22
-
- You need to have an Application Gateway v2 SKU instance. Rewriting headers isn't supported in the v1 SKU. If you don't have the v2 SKU, create an [Application Gateway v2 SKU](./tutorial-autoscale-ps.md) instance before you begin.
21
+
Before you begin, ensure you have the following requirements:
23
22
24
-
## Create required objects
23
+
-**Azure PowerShell**: You need Azure PowerShell installed locally or access to Azure Cloud Shell. The Azure PowerShell Az module version 1.0.0 or later is required. To check your version, run `Get-Module -ListAvailable Az`. If you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-azure-powershell).
24
+
-**Azure connection**: After verifying the PowerShell version, run `Connect-AzAccount` to authenticate with Azure.
25
+
-**Application Gateway v2**: You need an existing Application Gateway v2 SKU instance. Header rewriting is only supported in the v2 SKU (Standard_v2 or WAF_v2). If you don't have one, create an [Application Gateway v2 SKU](./tutorial-autoscale-ps.md) instance before you begin.
26
+
-**Proper permissions**: Ensure you have Contributor or Owner permissions on the Application Gateway resource.
25
27
26
-
To configure HTTP header rewrite, you need to complete these steps.
28
+
> [!IMPORTANT]
29
+
> Header rewrite functionality is only available with Application Gateway v2 SKU. The v1 SKU doesn't support this feature.
27
30
28
-
1. Create the objects that are required for HTTP header rewrite:
31
+
## Understanding HTTP header rewrite components
29
32
30
-
-**RequestHeaderConfiguration**: Used to specify the request header fields that you intend to rewrite and the new value for the headers.
33
+
To configure HTTP header rewrite, you need to understand and create the following components in a specific order:
31
34
32
-
-**ResponseHeaderConfiguration**: Used to specify the response header fields that you intend to rewrite and the new value for the headers.
35
+
### Core components
33
36
34
-
-**ActionSet**: Contains the configurations of the request and response headers specified previously.
37
+
1.**RequestHeaderConfiguration**: Specifies the request header fields you want to rewrite and their new values. Use this component to modify headers in client requests before they reach the backend servers.
35
38
36
-
-**Condition**: An optional configuration. Rewrite conditions evaluate the content of HTTP(S) requests and responses. The rewrite action will occur if the HTTP(S) request or response matches the rewrite condition.
39
+
2.**ResponseHeaderConfiguration**: Specifies the response header fields you want to rewrite and their new values. Use this component to modify headers in server responses before they reach the client.
37
40
38
-
If you associate more than one condition with an action, the action occurs only when all the conditions are met. In other words, the operation is a logical AND operation.
41
+
3.**ActionSet**: Contains the configurations of the request and response headers specified. Each action set represents a collection of header modifications to perform.
42
+
43
+
-**Condition**: An optional configuration. Rewrite conditions evaluate the content of HTTP(S) requests and responses. The rewrite action occurs if the HTTP(S) request or response matches the rewrite condition.
> Multiple conditions associated with an action use logical AND operation - all conditions must be met for the action to execute.
41
47
42
-
-**RuleSequence**: An optional configuration that helps determine the order in which rewrite rules execute. This configuration is helpful when you have multiple rewrite rules in a rewrite set. A rewrite rule that has a lower rule sequence value runs first. If you assign the same rule sequence value to two rewrite rules, the order of execution is non-deterministic.
48
+
5.**RewriteRule**: Combines multiple rewrite actions and rewrite conditions. Each rule defines when and how to modify headers.
43
49
44
-
If you don't specify the RuleSequence explicitly, a default value of 100 is set.
50
+
6.**RuleSequence** (Optional): Determines the execution order when you have multiple rewrite rules in a rewrite set. Rules with lower sequence values execute first. If you don't specify a value, the default is 100.
45
51
46
-
-**RewriteRuleSet**: Contains multiple rewrite rules that will be associated to a request routing rule.
52
+
> [!WARNING]
53
+
> If you assign the same sequence value to multiple rules, the execution order becomes non-deterministic.
47
54
48
-
2. Attach the RewriteRuleSet to a routing rule. The rewrite configuration is attached to the source listener via the routing rule. When you use a basic routing rule, the header rewrite configuration is associated with a source listener and is a global header rewrite. When you use a path-based routing rule, the header rewrite configuration is defined on the URL path map. In that case, it applies only to the specific path area of a site.
55
+
7.**RewriteRuleSet**: Contains multiple rewritten rules that are associated with a request routing rule.
49
56
50
-
You can create multiple HTTP header rewrite sets and apply each rewrite set to multiple listeners. But you can apply only one rewrite set to a specific listener.
57
+
### Application scope
51
58
52
-
## Sign in to Azure
59
+
The rewrite configuration scope depends on the routing rule type:
60
+
61
+
-**Basic routing rule**: Header rewrite configuration applies globally to all requests for the associated listener
62
+
-**Path-based routing rule**: Header rewrite configuration applies only to requests matching specific URL path patterns defined in the URL path map
63
+
64
+
> [!IMPORTANT]
65
+
> You can create multiple HTTP header rewrite sets and apply each set to multiple listeners, but only one rewrite set can be applied to a specific listener.
66
+
67
+
## Authenticate with Azure
68
+
69
+
Before configuring header rewrite rules, authenticate with Azure and select your subscription:
## Specify the HTTP header rewrite rule configuration
60
77
61
-
In this example, we'll modify a redirection URL by rewriting the location header in the HTTP response whenever the location header contains a reference to azurewebsites.net. To do this, we'll add a condition to evaluate whether the location header in the response contains azurewebsites.net. We'll use the pattern `(https?)://.*azurewebsites.net(.*)$`. And we'll use `{http_resp_Location_1}://contoso.com{http_resp_Location_2}` as the header value. This value will replace *azurewebsites.net* with *contoso.com* in the location header.
78
+
In this example, we modify a redirection URL by rewriting the location header in the HTTP response whenever the location header contains a reference to azurewebsite.net. To do this modification, we add a condition to evaluate whether the location header in the response contains azurewebsite.net. We use the pattern `(https?)://.*azurewebsite.net(.*)$`. And we use `{http_resp_Location_1}://contoso.com{http_resp_Location_2}` as the header value. This value replaces *azurewebsite.net* with *contoso.com* in the location header.
## Update the application gateway with the configuration for rewriting HTTP headers
84
103
85
-
In this example, the rewrite set would be associated instantly against a basic routing rule. In case of a path based routing rule, the association would not be enabled by default. The rewrite set can be enabled either via checking the paths on which it needs to be applied via portal or by providing a URL path map config specifying the RewriteRuleSet against each path option.
104
+
In this example, the rewrite set would be associated instantly against a basic routing rule. In a path based routing rule, the association wouldn't be enabled by default. The rewrite set can be enabled either via -- checking the paths on which it needs to be applied via portal or by providing a URL path map config specifying the RewriteRuleSet against each path option.
Write-Output "Rewrite rule set removed successfully"
101
133
```
102
134
103
135
## Next steps
104
136
105
-
To learn more about how to set up some common use cases, see [common header rewrite scenarios](./rewrite-http-headers-url.md).
137
+
Now that you learned how to configure HTTP header rewrite rules, explore these related articles:
138
+
139
+
-**Common scenarios**: Learn about [common header rewrite scenarios](./rewrite-http-headers-url.md) including security headers, custom routing, and backend server integration patterns.
140
+
141
+
-**Monitoring and troubleshooting**: Set up [Application Gateway diagnostics](./application-gateway-diagnostics.md) to monitor header rewrite operations and troubleshoot issues.
Copy file name to clipboardExpand all lines: articles/application-gateway/mutual-authentication-troubleshooting.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -123,13 +123,15 @@ Double check the certificate chain that was uploaded and remove the private key
123
123
#### Cause
124
124
125
125
There are two potential causes for this error:
126
+
126
127
***Parsing failure:** The certificate chain isn't in the correct format. Application Gateway expects certificate chains in PEM format with properly delimited individual certificates.
127
128
***Empty content:** The uploaded file contains only delimiters without actual certificate data between them.
128
129
129
130
#### Solution
130
131
131
132
Based on the specific cause, apply one of the following solutions:
132
-
***Format issue:** Ensure the certificate chain is in PEM format with each certificate properly delimited by `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----` markers. Each certificate should be on separate lines within these delimiters.
133
+
134
+
***Format issue:** Ensure the certificate chain is in PEM format with each certificate properly delimited by `-----BEGIN CERTIFICATE-----` and `-----END CERTIFICATE-----` markers. Each certificate should be on separate lines within these delimiters.
133
135
***Missing data:** Verify that the certificate file contains actual certificate data between the delimiters, not just empty delimiters.
Copy file name to clipboardExpand all lines: articles/traffic-manager/traffic-manager-subnet-override-cli.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,28 @@ az network traffic-manager endpoint update \
68
68
--remove subnets \
69
69
--type AzureEndpoints
70
70
```
71
+
### IPv6 Subnet Mapping Examples ###
72
+
You can also configure subnet mapping using IPv6 address ranges. Use the --type parameter with IPv6 and specify IPv6 addresses in CIDR or range format.
Copy file name to clipboardExpand all lines: articles/virtual-wan/how-to-routing-policies.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -367,13 +367,22 @@ Using the sample VPN configuration and VPN site from above, create firewall rule
367
367
368
368
#### Performance for Encrypted ExpressRoute
369
369
370
-
Configuring private routing policies with Encrypted ExpressRoute routes VPN ESP packets through the next hop security appliance deployed in the hub. As a result, you can expect Encrypted ExpressRoute maximum VPN tunnel throughput of 1 Gbps in both directions (inbound from on-premises and outbound from Azure). To achieve the maximum VPN tunnel throughput, consider the following deployment optimizations:
370
+
Configuring private routing policies with Encrypted ExpressRoute routes VPN ESP packets through the next hop security appliance deployed in the hub. Encrypted ExpressRoute performance is impacted by two main factors:
371
+
* You can expect Encrypted ExpressRoute VPN tunnels to have a maximum throughput of 1 Gbps due to ESP traffic being forwarded through the next hop security appliance deployed in the Virtual WAN hub.
372
+
* In practice, Encrypted ExpressRoute VPN tunnel throughput is also impacted by the maximum per-tunnel packets-per-second (PPS) supported by the VPN Gateway scale unit. For smaller packet sizes, you may see lower tunnel throughput. See [Site-to-site VPN performance](virtual-wan-faq.md#packets) for more information.
373
+
374
+
375
+
To achieve the maximum VPN tunnel throughput, consider the following deployment optimizations:
371
376
372
377
* Deploy Azure Firewall Premium instead of Azure Firewall Standard or Azure Firewall Basic.
373
378
* Ensure Azure Firewall processes the rule that allows traffic between the VPN tunnel endpoints (192.168.1.4 and 192.168.1.5 in the example above) first by making the rule have the highest priority in your Azure Firewall policy. For more information about Azure Firewall rule processing logic, see [Azure Firewall rule processing logic](../firewall/rule-processing.md#rule-processing-using-firewall-policy).
374
379
* Turn off deep-packet for traffic between the VPN tunnel endpoints. For information on how to configure Azure Firewall to exclude traffic from deep-packet inspection, reference [IDPS bypass list documentation](../firewall/premium-features.md#idps).
375
380
* Configure VPN devices to use GCMAES256 for both IPSEC Encryption and Integrity to maximize performance.
376
381
382
+
To achieve maximum aggregate throughput, consider the following optimization:
383
+
384
+
* To increase throughput between a single on-premises site and Azure, create multiple tunnels between on-premises devices and the Site-to-site VPN Gateway in Virtual WAN. Ensure your on-premises VPN device is configured to load-balance traffic across all active tunnels.
385
+
377
386
#### Direct routing to NVA instances for dual-role connectivity and firewall NVAs
0 commit comments