Skip to content

Commit e7bbf36

Browse files
committed
add related content section
1 parent 8b9bf4f commit e7bbf36

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

articles/frontdoor/rules-engine-scenarios.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can define various rule [actions](front-door-rules-engine-actions.md) based
3333

3434
This article covers common use cases supported by the rules engine, and how to configure these rules to meet your needs. It also includes Azure Resource Manager (ARM) template examples to help automate deployment of these capabilities.
3535

36-
### Scenario 1: Redirect using query string, URL path segments, or incoming hostname captures
36+
## Scenario 1: Redirect using query string, URL path segments, or incoming hostname captures
3737

3838
Managing redirects is critical for search engine optimization (SEO), user experience, and the proper functioning of a website. Azure Front Door's rules engine and server variables allow you to efficiently manage batch redirects based on various parameters.
3939

@@ -75,7 +75,7 @@ Managing redirects is critical for search engine optimization (SEO), user experi
7575

7676
- **Redirect based on fixed-length URL path segments:** You can redirect requests to different origins based on fixed-length URL path segment by capturing the URL segments using `{variable:offset:length}`. For more information, see [Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format).
7777

78-
For example, consider a scenario where the tenant ID is embedded in the URL segment and is always 6 characters long, such as: `https://api.contoso.com/{tenantId}/xyz`. To extract `{tenantId}` from the URL and decide the correct redirect to use in the format of `tenantId.backend.com/xyz`.
78+
For example, consider a scenario where the tenant ID is embedded in the URL segment and is always six characters long, such as: `https://api.contoso.com/{tenantId}/xyz`. To extract `{tenantId}` from the URL and decide the correct redirect to use in the format of `tenantId.backend.com/xyz`.
7979

8080
This approach eliminates the need to create a separate rule for each tenant ID, allowing you to handle dynamic routing with fewer rules.
8181

@@ -194,9 +194,9 @@ Managing redirects is critical for search engine optimization (SEO), user experi
194194
}
195195
```
196196

197-
### Scenario 2: Populate or modify a response header based on a request header value
197+
## Scenario 2: Populate or modify a response header based on a request header value
198198

199-
In some scenarios, you may need to populate or modify a response header based on a request header value.
199+
In some scenarios, you might need to populate or modify a response header based on a request header value.
200200

201201
For example, you can add CORS header where needed to serve scripts on multiple origins from the same CDN domain, and response must contain the same FQDN in `Access-Control-Allow-Origin` header as the request origin header, rather than a wildcard allowing all domains (*) to enhance security. You can achieve it by using the `{http_req_header_Origin}` server variable to set the response header.
202202

@@ -245,7 +245,7 @@ For example, you can add CORS header where needed to serve scripts on multiple o
245245
}
246246
```
247247

248-
### Scenario 3: Rename a response header to a brand-specific one
248+
## Scenario 3: Rename a response header to a brand-specific one
249249

250250
You can rename a response header generated by a cloud provider by adding a new custom response header and deleting the original.
251251

@@ -289,11 +289,11 @@ For example, you can replace the response header `X-Azure-Backend-ID` with a bra
289289
}
290290
```
291291

292-
### Scenario 4: A/B testing (experimentation)
292+
## Scenario 4: A/B testing (experimentation)
293293

294294
Splitting incoming traffic into two origin groups can be is useful in A/B testing, rolling deployments, or load balancing without complex backend logic.
295295

296-
For example, you can split incoming traffic based on the client port number. A rule can match client ports that end in 1, 3, 5, 7, or 9 and forward those requests to an *experiment-origin-group*. All other traffic continues to the default origin group per route settings. The previous regex is just an example, You can explore and test your own expressions using tools like [regex101](https://regex101.com/).
296+
For example, you can split incoming traffic based on the client port number. A rule can match client ports that end in 1, 3, 5, 7, or 9 and forward those requests to an *experiment-origin-group*. All other traffic continues to the default origin group per route settings. The previous regex is just an example. You can explore and test your own expressions using tools like [regex101](https://regex101.com/).
297297

298298
> [!NOTE]
299299
> Since client ports are random, this method typically results in an approximate 50/50 traffic split. However, the presence of any proxies or load balancers between clients and the Front Door might affect this assumption due to factors like connection reuse or source port rewriting. Use logs or metrics to validate the actual behavior in your environment.
@@ -345,7 +345,7 @@ For example, you can split incoming traffic based on the client port number. A r
345345
}
346346
```
347347

348-
### Scenario 5: Redirect with URL path modification and preserve capability
348+
## Scenario 5: Redirect with URL path modification and preserve capability
349349

350350
In some scenarios, you might need to add new segments or remove some segments while preserving the rest of the URL path.
351351

@@ -384,7 +384,7 @@ For example, if you want to redirect `https://domain.com/seg0/seg1/seg2/seg3` to
384384
}
385385
```
386386

387-
### Scenario 6: Redirect by removing fixed parts of a URL path
387+
## Scenario 6: Redirect by removing fixed parts of a URL path
388388

389389
You can remove fixed segments of known size from a URL path, such as country codes (us) or locales (en-us), while preserving the rest of the URL path.
390390

@@ -439,7 +439,7 @@ To achieve this, use `{variable:offset} `, which includes the server variable af
439439
}
440440
```
441441

442-
### Scenario 7: URL rewrite by removing one or more segments of URL path
442+
## Scenario 7: URL rewrite by removing one or more segments of URL path
443443

444444
You can remove one or more segments from a URL path, such as country codes (us) or locales (en-us), while preserving the rest of the URL path.
445445

@@ -480,7 +480,7 @@ To achieve this, use the `{url_path:seg#:length}` server variable format to capt
480480
}
481481
```
482482

483-
### Scenario 8: Use regex to reduce the number of rule conditions and avoid hitting limits
483+
## Scenario 8: Use regex to reduce the number of rule conditions and avoid hitting limits
484484

485485
Using regex in rule conditions can significantly reduce the number of rules required, which helps avoid rule limits that can be a blocker for customers who need conditions or actions for hundreds of clients.
486486

@@ -539,9 +539,9 @@ Instead of creating individual rules for each possible client ID, you can use a
539539
}
540540
```
541541

542-
### Scenario 9: Modify origin redirects using response header captures
542+
## Scenario 9: Modify origin redirects using response header captures
543543

544-
You can make action fields dynamic by using response header values as server variables. This is particularly useful when origin servers issue redirects that reference their own domain names.
544+
You can make action fields dynamic by using response header values as server variables. This is useful when origin servers issue redirects that reference their own domain names.
545545

546546
**The Problem:** Origin servers like Azure App Service commonly issue redirect URLs that reference their own domain name (for example, `contoso.azurewebsites.net`). If these URLs reach the client unmodified, the next request bypasses Azure Front Door, which disrupts the user's navigation experience.
547547

@@ -606,9 +606,9 @@ For more information, see [Preserve the original HTTP host name between a revers
606606
}
607607
```
608608

609-
### Scenario 10: If-elseif-else rules
609+
## Scenario 10: If-elseif-else rules
610610

611-
The Azure Front Door rules engine doesn't natively support traditional conditional logic with "if-elseif-else" structures. By default, all rules are independently evaluated as "if condition1 then action1," "if condition2 then action2," and so forth. When multiple conditions are met simultaneously, multiple corresponding actions are executed.
611+
The Azure Front Door rules engine doesn't natively support traditional conditional logic with "if-elseif-else" structures. By default, all rules are independently evaluated as "if condition1 then action1", "if condition2 then action2", and so forth. When multiple conditions are met simultaneously, multiple corresponding actions are executed.
612612

613613
However, you can emulate "if-elseif-else" logic by using the **Stop evaluating remaining rules** feature to create conditional branching that resembles:
614614

@@ -632,7 +632,7 @@ However, you can emulate "if-elseif-else" logic by using the **Stop evaluating r
632632
633633
:::image type="content" source="./media/rules-engine-scenarios/if-elseif-else-rules-final.png" alt-text="Screenshot that shows how to place if-elseif-else rules as the final ruleset for the route." lightbox="./media/rules-engine-scenarios/if-elseif-else-rules-final.png":::
634634

635-
### Scenario 11: Removing query strings from incoming URLs using URL redirects
635+
## Scenario 11: Removing query strings from incoming URLs using URL redirects
636636

637637
You can remove query strings from incoming URLs by implementing a 3xx URL redirect that guides users back to the Azure Front Door endpoint with the query strings removed.
638638

@@ -684,7 +684,7 @@ The following example demonstrates how to remove the entire query string from in
684684
}
685685
```
686686

687-
### Scenario 12: Append SAS token in query string to authenticate Azure Front Door to Azure Storage
687+
## Scenario 12: Append SAS token in query string to authenticate Azure Front Door to Azure Storage
688688

689689
You can protect files in your storage account by changing the access to your storage containers from public to private and using Shared Access Signatures (SAS) to grant restricted access rights to your Azure Storage resources from Azure Front Door without exposing your account key. You can also accomplish this using Managed Identity. For more information, see [Use managed identities to authenticate to origins](/azure/frontdoor/origin-authentication-with-managed-identities).
690690

@@ -757,11 +757,11 @@ The rule configuration redirects all HTTPS requests that don't already contain t
757757
}
758758
```
759759

760-
### Scenario 13: Add security headers with rules engine
760+
## Scenario 13: Add security headers with rules engine
761761

762762
You can use the Azure Front Door rules engine to add security headers that help prevent browser-based vulnerabilities, such as HTTP Strict-Transport-Security (HSTS), X-XSS-Protection, Content-Security-Policy, and X-Frame-Options.
763763

764-
For example, you can add a *Content-Security-Policy* header to all incoming requests that match the path defined in the route associated with your rules engine configuration. In this configuration, use `script-src 'self' https://apiphany.portal.azure-api.net`as the header value to only allow scripts from the trusted site `https://apiphany.portal.azure-api.net` to run on the application.
764+
For example, you can add a *Content-Security-Policy* header to all incoming requests that match the path defined in the route associated with your rules engine configuration. In this configuration, use `script-src 'self' https://apiphany.portal.azure-api.net` as the header value to only allow scripts from the trusted site `https://apiphany.portal.azure-api.net` to run on the application.
765765

766766
:::image type="content" source="./media/rules-engine-scenarios/add-security-headers.png" alt-text="Screenshot that shows how to add security headers with rules engine." lightbox="./media/rules-engine-scenarios/add-security-headers.png":::
767767

@@ -792,3 +792,9 @@ For example, you can add a *Content-Security-Policy* header to all incoming requ
792792
}
793793
}
794794
```
795+
796+
## Related content
797+
798+
- [What is a rule set in Azure Front Door?](/azure/frontdoor/front-door-rules-engine)
799+
- [Rule set actions](/azure/frontdoor/front-door-rules-engine-actions)
800+
- [Configure rule sets in Azure Front Door](/azure/frontdoor/standard-premium/how-to-configure-rule-set)

0 commit comments

Comments
 (0)