Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this guide you learn to create a Rewrite set for your Application Gateway and configure Secure and HttpOnly ApplicationGatewayAffinity cookie.
Prerequisites
- You must have an Azure subscription. You can create a Trial before you begin.
- An existing Application Gateway resource configured with at least one Listener, Rule, Backend Setting and Backend Pool configuration. If you don't have one, you can create one by following the QuickStart guide.
Important
If your backend application returns multiple Set-Cookie headers (for example, application cookies in addition to the ApplicationGatewayCookie), the simple pattern matching approach shown in this article will apply the rewrite to all Set-Cookie headers. To target only the ApplicationGatewayCookie specifically, use the HeaderValueMatcher pattern matching feature. For more information, see Pattern matching for Set-Cookie headers.
Creating a Rewrite set
- Sign in to the Azure portal.
- Navigate to the required Application Gateway resource.
- Select Rewrites in the left pane.
- Select Rewrite set.
- Under the Name and Association tab
- Specify a name for this new rewrite set.
- Select the routing rules for which you wish to rewrite the ApplicationGatewayAffinity cookie's flag.
- Select Next.
- Select "Add rewrite rule"
- Enter a name for the rewrite rule.
- Enter a numeric value for Rule Sequence field.
- Select "Add condition"
- Now open the "If" condition box and use the following details.
- Type of variable to check - HTTP header
- Header type - Response header
- Header name - Common header
- Common header - Set-Cookie
- Case-sensitive - No
- Operator - equal (=)
- Pattern to match - (.*)
Note
This pattern
(.*)matches all Set-Cookie headers. If you need to target only the ApplicationGatewayCookie and preserve other Set-Cookie headers, see Pattern matching for Set-Cookie headers to use the HeaderValueMatcher feature. - To save these details, select OK.
- Go to the Then box to specify action details.
- Rewrite type - Response header
- Action type - Set
- Header name - Common header
- Common header - Set-Cookie
- Header value - {http_resp_Set-Cookie_1}; HttpOnly; Secure
- Select OK
- Select Update to save the rewrite set configurations.