Skip to content

Commit 099b35e

Browse files
authored
Merge pull request #174112 from xstof/xstof-add-appgw-FDID-check
Document how to check Front Door FDID header in Application Gateway custom WAF rule
2 parents d76fe03 + 958d149 commit 099b35e

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

articles/frontdoor/front-door-faq.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ sections:
138138
139139
- Azure Front Door also supports the *AzureFrontDoor.Frontend* service tag, which provides the list of IP addresses that clients use when connecting to Front Door. You can use the *AzureFrontDoor.Frontend* service tag when you’re controlling the outbound traffic that should be allowed to connect to services deployed behind Azure Front Door. Azure Front Door also supports an additional service tag, *AzureFrontDoor.FirstParty*, to integrate internally with other Azure services. See [available service tags](../virtual-network/service-tags-overview.md#available-service-tags) for more details on Azure Front Door service tags use cases.
140140
141+
If using Application Gateway as a backend to Azure Front Door, then the check on the `X-Azure-FDID` header can be done in a custom WAF rule. For more information, see [Create and use Web Application Firewall v2 custom rules on Application Gateway](../web-application-firewall/ag/create-custom-waf-rules.md#example-7).
142+
141143
- question: |
142144
Can the anycast IP change over the lifetime of my Front Door?
143145
answer: |

articles/web-application-firewall/ag/create-custom-waf-rules.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,66 @@ Corresponding JSON:
543543
}
544544
```
545545

546+
## Example 7
547+
548+
It is not uncommon to see Azure Front Door deployed in front of Application Gateway. In order to make sure the traffic received by Application Gateway comes from the Front Door deployment, the best practice is to check if the `X-Azure-FDID` header contains the expected unique value. For more information on this, please see [How to lock down the access to my backend to only Azure Front Door](../../frontdoor/front-door-faq.yml#how-do-i-lock-down-the-access-to-my-backend-to-only-azure-front-door-)
549+
550+
Logic: **not** p
551+
552+
```azurepowershell
553+
$expectedFDID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
554+
$variable = New-AzApplicationGatewayFirewallMatchVariable `
555+
-VariableName RequestHeaders `
556+
-Selector X-Azure-FDID
557+
558+
$condition = New-AzApplicationGatewayFirewallCondition `
559+
-MatchVariable $variable `
560+
-Operator Equal `
561+
-MatchValue $expectedFDID `
562+
-Transform Lowercase `
563+
-NegationCondition $True
564+
565+
$rule = New-AzApplicationGatewayFirewallCustomRule `
566+
-Name blockNonAFDTraffic `
567+
-Priority 2 `
568+
-RuleType MatchRule `
569+
-MatchCondition $condition `
570+
-Action Block
571+
```
572+
573+
And here is the corresponding JSON:
574+
575+
```json
576+
{
577+
"customRules": [
578+
{
579+
"name": "blockNonAFDTraffic",
580+
"priority": 2,
581+
"ruleType": "MatchRule",
582+
"action": "Block",
583+
"matchConditions": [
584+
{
585+
"matchVariables": [
586+
{
587+
"variableName": "RequestHeaders",
588+
"selector": "X-Azure-FDID"
589+
}
590+
],
591+
"operator": "Equal",
592+
"negationConditon": true,
593+
"matchValues": [
594+
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
595+
],
596+
"transforms": [
597+
"Lowercase"
598+
]
599+
}
600+
]
601+
}
602+
]
603+
}
604+
```
605+
546606
## Next steps
547607

548608
After you create your custom rules, you can learn how to view your WAF logs. For more information, see [Application Gateway diagnostics](../../application-gateway/application-gateway-diagnostics.md#diagnostic-logging).

0 commit comments

Comments
 (0)