Skip to content

Commit 309eae2

Browse files
authored
Merge pull request #288911 from paulth1/application-gateway-articles
[AQ] edit pass: application-gateway-articles
2 parents e66d68e + 6dc1fbb commit 309eae2

File tree

3 files changed

+124
-140
lines changed

3 files changed

+124
-140
lines changed
Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Route traffic using parameter based path selection in portal - Azure Application Gateway
3-
description: Learn how to use the Azure portal to configure an Azure Application Gateway to choose the backend pool based on the value of a header, part of URL, or query string in the request.
2+
title: Route traffic using parameter-based path selection in portal - Azure Application Gateway
3+
description: Use the Azure portal to configure an application gateway to choose the backend pool based on the value of a header, part of a URL, or a query string in the request.
44
services: application-gateway
55
author: greg-lindsay
66
ms.service: azure-application-gateway
@@ -9,51 +9,47 @@ ms.date: 09/10/2024
99
ms.author: greglin
1010
ms.custom: mvc
1111
---
12-
# Perform parameter based path selection with Azure Application Gateway - Azure portal
12+
# Perform parameter-based path selection with Azure Application Gateway - Azure portal
1313

14-
This article describes how to use the Azure portal to configure an [Application Gateway v2 SKU](./application-gateway-autoscaling-zone-redundant.md) instance to perform parameter based path selection by combining the capabilities of URL Rewrite with path-based routing.
14+
This article describes how to use the Azure portal to configure an [Azure Application Gateway v2 SKU](./application-gateway-autoscaling-zone-redundant.md) instance to perform parameter-based path selection by combining the capabilities of URL Rewrite with path-based routing.
1515

1616
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
1717

1818
## Before you begin
1919

20-
You need to have an Application Gateway v2 SKU instance to complete the steps in this article. URL rewrite and rewriting headers aren'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-
20+
You need to have an Application Gateway v2 SKU instance to finish the steps in this article. URL Rewrite and rewriting headers aren'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.
2221

2322
## Sign in to Azure
2423

2524
Sign in to the [Azure portal](https://portal.azure.com/) with your Azure account.
2625

27-
## Configure parameter based path selection
28-
29-
For this example, you have a shopping website and the product category is passed as query string in the URL, and you want to route the request to backend based on the query string, then:
30-
31-
**Step 1:** Create a path-map as shown in the following image:
26+
## Configure parameter-based path selection
3227

33-
:::image type="content" source="./media/rewrite-http-headers-url/url-scenario1-1.png" alt-text="A screenshot of URL rewrite scenario 1-1.":::
28+
For this example, you have a shopping website. The product category is passed as a query string in the URL. To route the request to the backend based on the query string, follow these steps.
3429

35-
**Step 2 (a):** Create a rewrite set which has 3 rewrite rules:
30+
1. Create a path map.
3631

37-
* The first rule has a condition that checks the *query_string* variable for *category=shoes* and has an action that rewrites the URL path to /*listing1* and has **Reevaluate path map** enabled
32+
:::image type="content" source="./media/rewrite-http-headers-url/url-scenario1-1.png" alt-text="Screenshot that shows a URL Rewrite scenario 1-1.":::
3833

39-
* The second rule has a condition that checks the *query_string* variable for *category=bags* and has an action that rewrites the URL path to /*listing2* and has **Reevaluate path map** enabled
34+
1. Create a rewrite set that has three rewrite rules:
4035

41-
* The third rule has a condition that checks the *query_string* variable for *category=accessories* and has an action that rewrites the URL path to /*listing3* and has **Reevaluate path map** enabled
36+
* The first rule has a condition that checks the `query_string` variable for `category=shoes`. An action rewrites the URL path to `/listing1`. **Reevaluate path map** is enabled.
37+
* The second rule has a condition that checks the `query_string` variable for `category=bags`. An action rewrites the URL path to `/listing2`. **Reevaluate path map** is enabled.
38+
* The third rule has a condition that checks the `query_string` variable for `category=accessories`. An action rewrites the URL path to `/listing3`. **Reevaluate path map** is enabled.
4239

43-
:::image type="content" source="./media/rewrite-http-headers-url/url-scenario1-2.png" alt-text="A screenshot of URL rewrite scenario 1-2.":::
40+
:::image type="content" source="./media/rewrite-http-headers-url/url-scenario1-2.png" alt-text="Screenshot that shows the URL Rewrite scenario 1-2.":::
4441

45-
46-
**Step 2 (b):** Associate this rewrite set with the default path of the previous path-based rule:
42+
1. Associate this rewrite set with the default path of the previous path-based rule.
4743

48-
:::image type="content" source="./media/rewrite-http-headers-url/url-scenario1-3.png" alt-text="A screenshot of URL rewrite scenario 1-3.":::
44+
:::image type="content" source="./media/rewrite-http-headers-url/url-scenario1-3.png" alt-text="Screenshot that shows the URL rewrite scenario 1-3.":::
4945

50-
If the user requests *contoso.com/listing?category=any*, then it's matched with the default path since none of the path patterns in the path map (/listing1, /listing2, /listing3) are matched. Since you associated the previous rewrite set with this path, this rewrite set is evaluated. Because the query string doesn't match the condition in any of the 3 rewrite rules in this rewrite set, no rewrite action takes place. Therefore, the request is routed unchanged to the backend associated with the default path (which is *GenericList*).
46+
If the user requests `contoso.com/listing?category=any`, it's matched with the default path because the path patterns in the path map (`/listing1`, /`listing2`, /`listing3`) don't match. Because you associated the previous rewrite set with this path, this rewrite set is evaluated. The query string doesn't match the condition in any of the three rewrite rules in this rewrite set, so no rewrite action takes place. The request is routed unchanged to the backend associated with the default path (which is `GenericList`).
5147

52-
If the user requests *contoso.com/listing?category=shoes*, then the default path is matched. However, in this case, the condition in the first rule matches. Therefore, the action associated with the condition is executed, which rewrites the URL path to /*listing1* and reevaluates the path-map. When the path-map is reevaluated, the request matches the path associated with pattern */listing1* and the request is routed to the backend associated with this pattern (ShoesListBackendPool).
48+
If the user requests `contoso.com/listing?category=shoes`, the default path is matched. In this case, the condition in the first rule matches. The action associated with the condition is executed, which rewrites the URL path to `/listing1` and reevaluates the path map. When the path map is reevaluated, the request matches the path associated with the pattern `/listing1`. The request is routed to the backend associated with this pattern (`ShoesListBackendPool`).
5349

5450
> [!NOTE]
55-
> This scenario can be extended to any header or cookie value, URL path, query string or server variables based on the conditions defined and essentially enables you to route requests based on those conditions.
51+
> You can extend this scenario to any header or cookie value, URL path, query string, or server variables based on the conditions defined. You can then route requests based on those conditions.
5652
57-
## Next steps
53+
## Related content
5854

59-
To learn more about how to set up some common use cases, see [common header rewrite scenarios](./rewrite-http-headers-url.md).
55+
To learn more about how to set up some common use cases, see [Common header rewrite scenarios](./rewrite-http-headers-url.md).
Lines changed: 55 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Rewrite HTTP request and response headers in portal - Azure Application Gateway
3-
description: Learn how to use the Azure portal to configure an Azure Application Gateway to rewrite the HTTP headers in the requests and responses passing through the gateway
3+
description: Use the Azure portal to configure an application gateway to rewrite the HTTP headers in the requests and responses that pass through the gateway.
44
services: application-gateway
55
author: greg-lindsay
66
ms.service: azure-application-gateway
@@ -9,120 +9,109 @@ ms.date: 11/13/2019
99
ms.author: greglin
1010
ms.custom: mvc
1111
---
12+
1213
# Rewrite HTTP request and response headers with Azure Application Gateway - Azure portal
1314

14-
This article describes how to use the Azure portal 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 the Azure portal to configure an [Azure Application Gateway v2 SKU](./application-gateway-autoscaling-zone-redundant.md) instance to rewrite the HTTP headers in requests and responses.
1516

1617
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
1718

1819
## Before you begin
1920

20-
You need to have an Application Gateway v2 SKU instance to complete the steps in this article. 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+
You need to have an Application Gateway v2 SKU instance to finish the steps in this article. 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.
2122

2223
## Create required objects
2324

24-
To configure HTTP header rewrite, you need to complete these steps.
25+
To configure HTTP header rewrite, follow these steps.
2526

26-
1. Create the objects that are required for HTTP header rewrite:
27+
1. Create the objects that are required for an HTTP header rewrite:
2728

2829
- **Rewrite action**: Used to specify the request and request header fields that you intend to rewrite and the new value for the headers. You can associate one or more rewrite conditions with a rewrite action.
30+
- **Rewrite 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.
2931

30-
- **Rewrite 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.
31-
32-
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.
33-
34-
- **Rewrite rule**: Contains multiple rewrite action / rewrite condition combinations.
35-
36-
- **Rule sequence**: Helps determine the order in which the 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.
32+
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.
3733

34+
- **Rewrite rule**: Contains multiple rewrite action/rewrite condition combinations.
35+
- **Rule sequence**: Helps determine the order in which the 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 nondeterministic.
3836
- **Rewrite set**: Contains multiple rewrite rules that will be associated with a request routing rule.
3937

40-
2. Attach the rewrite set 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.
38+
1. Attach the rewrite set to a routing rule. The rewrite configuration is attached to the source listener via the routing rule.
39+
40+
- When you use a basic routing rule, the header rewrite configuration is associated with a source listener and is a global header rewrite.
41+
- 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.
4142

4243
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.
4344

4445
## Sign in to Azure
4546

4647
Sign in to the [Azure portal](https://portal.azure.com/) with your Azure account.
4748

48-
## Configure header rewrite
49+
## Configure a header rewrite
4950

50-
In this example, we'll modify a redirection URL by rewriting the location header in the HTTP response sent by a backend application.
51+
In this example, we modify a redirection URL by rewriting the location header in the HTTP response sent by a backend application.
5152

5253
1. Select **All resources**, and then select your application gateway.
5354

54-
2. Select **Rewrites** in the left pane.
55+
1. In the service pane, select **Rewrites**.
5556

56-
3. Select **Rewrite set**:
57+
1. Select **Rewrite set**.
5758

58-
![Add rewrite set](media/rewrite-http-headers-portal/add-rewrite-set.png)
59+
![Screenshot that shows adding a rewrite set.](media/rewrite-http-headers-portal/add-rewrite-set.png)
5960

60-
4. Provide a name for the rewrite set and associate it with a routing rule:
61+
1. Provide a name for the rewrite set and associate it with a routing rule:
6162

62-
- Enter the name for the rewrite set in the **Name** box.
63-
- Select one or more of the rules listed in the **Associated routing rules** list. You can select only rules that haven't been associated with other rewrite sets. The rules that have already been associated with other rewrite sets are dimmed.
64-
- Select **Next**.
63+
1. In the **Name** box, enter the name for the rewrite set.
64+
1. In the **Associated routing rules** list, select one or more rules. Select only rules not already associated with other rewrite sets. Rules already associated with other rewrite sets are dimmed.
65+
1. Select **Next**.
6566

66-
![Add name and association](media/rewrite-http-headers-portal/name-and-association.png)
67-
68-
5. Create a rewrite rule:
69-
70-
- Select **Add rewrite rule**.
71-
72-
![Add rewrite rule](media/rewrite-http-headers-portal/add-rewrite-rule.png)
73-
74-
- Enter a name for the rewrite rule in the **Rewrite rule name** box. Enter a number in the **Rule sequence** box.
75-
76-
![Add rewrite rule name](media/rewrite-http-headers-portal/rule-name.png)
77-
78-
6. In this example, we'll rewrite the location header only when it contains a reference to azurewebsites.net. To do this, add a condition to evaluate whether the location header in the response contains azurewebsites.net:
79-
80-
- Select **Add condition** and then select the box containing the **If** instructions to expand it.
81-
82-
![Add a condition](media/rewrite-http-headers-portal/add-condition.png)
83-
84-
- In the **Type of variable to check** list, select **HTTP header**.
85-
86-
- In the **Header type** list, select **Response**.
87-
88-
- Because in this example we're evaluating the location header, which is a common header, select **Common header** under **Header name**.
89-
90-
- In the **Common header** list, select **Location**.
67+
![Screenshot that shows adding a name and association.](media/rewrite-http-headers-portal/name-and-association.png)
9168

92-
- Under **Case-sensitive**, select **No**.
69+
1. Create a rewrite rule:
9370

94-
- In the **Operator** list, select **equal (=)**.
71+
1. Select **Add rewrite rule**.
9572

96-
- Enter a regular expression pattern. In this example, we'll use the pattern `(https?):\/\/.*azurewebsites.net(.*)$`.
73+
![Screenshot that shows adding a rewrite rule.](media/rewrite-http-headers-portal/add-rewrite-rule.png)
9774

98-
- Select **OK**.
75+
1. In the **Rewrite rule name** box, enter a name for the rewrite rule. In the **Rule sequence** box, enter a number.
9976

100-
![Configure an If condition](media/rewrite-http-headers-portal/condition.png)
77+
![Screenshot that shows adding a rewrite rule name.](media/rewrite-http-headers-portal/rule-name.png)
10178

102-
7. Add an action to rewrite the location header:
79+
1. In this example, we rewrite the location header only when it contains a reference to `azurewebsites.net`. To do this step, add a condition to evaluate whether the location header in the response contains `azurewebsites.net`:
10380

104-
- In the **Action type** list, select **Set**.
81+
1. Select **Add condition**, and then select the box containing the **If** instructions to expand it.
10582

106-
- In the **Header type** list, select **Response**.
83+
![Screenshot that shows adding a condition.](media/rewrite-http-headers-portal/add-condition.png)
10784

108-
- Under **Header name**, select **Common header**.
85+
1. In the **Type of variable to check** list, select **HTTP header**.
86+
1. In the **Header type** list, select **Response**.
87+
1. Under **Header name**, select **Common header**. In this example, we're evaluating the location header, which is a common header.
88+
1. In the **Common header** list, select **Location**.
89+
1. Under **Case-sensitive**, select **No**.
90+
1. In the **Operator** list, select **equal (=)**.
91+
1. Enter a regular expression pattern. In this example, we use the pattern `(https?):\/\/.*azurewebsites.net(.*)$`.
92+
1. Select **OK**.
10993

110-
- In the **Common header** list, select **Location**.
94+
![Screenshot that shows configuring an If condition.](media/rewrite-http-headers-portal/condition.png)
11195

112-
- Enter the header value. In this example, 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.
96+
1. Add an action to rewrite the location header:
11397

114-
- Select **OK**.
98+
1. In the **Action type** list, select **Set**.
99+
1. In the **Header type** list, select **Response**.
100+
1. Under **Header name**, select **Common header**.
101+
1. In the **Common header** list, select **Location**.
102+
1. Enter the header value. In this example, we use `{http_resp_Location_1}://contoso.com{http_resp_Location_2}` as the header value. This value replaces `azurewebsites.net` with `contoso.com` in the location header.
103+
1. Select **OK**.
115104

116-
![Add an action](media/rewrite-http-headers-portal/action.png)
105+
![Screenshot that shows adding an action.](media/rewrite-http-headers-portal/action.png)
117106

118-
8. Select **Create** to create the rewrite set:
107+
1. Select **Create** to create the rewrite set.
119108

120-
![Select Create](media/rewrite-http-headers-portal/create.png)
109+
![Screenshot that shows selecting Create.](media/rewrite-http-headers-portal/create.png)
121110

122-
9. The Rewrite set view will open. Verify that the rewrite set you created is in the list of rewrite sets:
111+
1. The **Rewrites** pane opens. Verify that the rewrite set you created is in the list of rewrite sets.
123112

124-
![Rewrite set view](media/rewrite-http-headers-portal/rewrite-set-list.png)
113+
![Screenshot that shows rewriting a set view.](media/rewrite-http-headers-portal/rewrite-set-list.png)
125114

126-
## Next steps
115+
## Related content
127116

128-
To learn more about how to set up some common use cases, see [common header rewrite scenarios](./rewrite-http-headers-url.md).
117+
To learn more about how to set up some common use cases, see [Common header rewrite scenarios](./rewrite-http-headers-url.md).

0 commit comments

Comments
 (0)