Skip to content

Commit 3b718cb

Browse files
authored
Merge pull request #109163 from vhorne/waf-fd-ip-restrict
add portal steps
2 parents b192a1e + 4fb35cd commit 3b718cb

File tree

3 files changed

+70
-9
lines changed

3 files changed

+70
-9
lines changed

articles/web-application-firewall/afds/waf-front-door-configure-ip-restriction.md

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,76 @@ services: web-application-firewall
55
author: vhorne
66
ms.service: web-application-firewall
77
ms.topic: article
8-
ms.date: 08/21/2019
9-
ms.author: victorh
10-
ms.reviewer: tyao
8+
ms.date: 03/26/2020
9+
ms.author: tyao
1110
---
1211

1312
# Configure an IP restriction rule with a Web Application Firewall for Azure Front Door
14-
This article shows you how to configure IP restriction rules in a Web Application Firewall (WAF) for Azure Front Door by using the Azure CLI, Azure PowerShell, or an Azure Resource Manager template.
13+
14+
This article shows you how to configure IP restriction rules in a Web Application Firewall (WAF) for Azure Front Door by using the Azure portal, Azure CLI, Azure PowerShell, or an Azure Resource Manager template.
1515

1616
An IP address–based access control rule is a custom WAF rule that lets you control access to your web applications. It does this by specifying a list of IP addresses or IP address ranges in Classless Inter-Domain Routing (CIDR) format.
1717

18-
By default, your web application is accessible from the internet. If you want to limit access to clients from a list of known IP addresses or IP address ranges, you may create an IP matching rule that contains the list of IP addresses as matching values and sets operator to "Not" (negate is true) and the action to **Block**. After an IP restriction rule is applied, requests that originate from addresses outside this allowed list receive a 403 Forbidden response.
18+
By default, your web application is accessible from the Internet. If you want to limit access to clients from a list of known IP addresses or IP address ranges, you may create an IP matching rule that contains the list of IP addresses as matching values and sets operator to "Not" (negate is true) and the action to **Block**. After an IP restriction rule is applied, requests that originate from addresses outside this allowed list receive a 403 Forbidden response.
19+
20+
## Configure a WAF policy with the Azure portal
21+
22+
### Prerequisites
23+
24+
Create an Azure Front Door profile by following the instructions described in [Quickstart: Create a Front Door for a highly available global web application](../../frontdoor/quickstart-create-front-door.md).
25+
26+
### Create a WAF policy
27+
28+
1. On the Azure portal, select **Create a resource**, type **Web application firewall** in the search box, and then select **Web Application Firewall (WAF)**.
29+
2. Select **Create**.
30+
3. On the **Create a WAF policy** page, use the following values to complete the **Basics** tab:
31+
32+
|Setting |Value |
33+
|---------|---------|
34+
|Policy for |Global WAF (Front Door)|
35+
|Subscription |Select your subscription|
36+
|Resource group |Select the resource group where your Front Door is.|
37+
|Policy name |Type a name for your policy|
38+
|Policy state |Enabled|
39+
40+
Select **Next: Policy settings**
41+
42+
1. On the **Policy settings** tab, select **Prevention**. For the **Block response body**, type *You've been blocked!* so you can see that your custom rule is in effect.
43+
2. Select **Next: Managed rules**.
44+
3. Select **Next: Custom rules**.
45+
4. Select **Add custom rule**.
46+
5. On the **Add custom rule** page, use the following test values to create a custom rule:
47+
48+
|Setting |Value |
49+
|---------|---------|
50+
|Custom rule name |FdWafCustRule|
51+
|Status |Enabled|
52+
|Rule type |Match|
53+
|Priority |100|
54+
|Match type |IP address|
55+
|Match variable|RemoteAddr|
56+
|Operation|Does not contain|
57+
|IP address or range|10.10.10.0/24|
58+
|Then|Deny traffic|
59+
60+
:::image type="content" source="../media/waf-front-door-configure-ip-restriction/custom-rule.png" alt-text="Custom rule":::
61+
62+
Select **Add**.
63+
6. Select **Next: Association**.
64+
7. Select **Add frontend host**.
65+
8. For **Frontend host**, select your frontend host and select **Add**.
66+
9. Select **Review + create**.
67+
10. After your policy validation passes, select **Create**.
68+
69+
### Test your WAF policy
70+
71+
1. After your WAF policy deployment completes, browse to your Front Door frontend host name.
72+
2. You should see your custom block message.
73+
74+
:::image type="content" source="../media/waf-front-door-configure-ip-restriction/waf-rule-test.png" alt-text="WAF rule test":::
75+
76+
> [!NOTE]
77+
> A private IP address was intentionally used in the custom rule to guarantee the rule would trigger. In an actual deployment, create *allow* and *deny* rules using IP addresses for your particular situation.
1978
2079
## Configure a WAF policy with the Azure CLI
2180

@@ -48,7 +107,9 @@ In the following examples:
48107
- Replace *IPAllowPolicyExampleCLI* with your unique policy created earlier.
49108
- Replace *ip-address-range-1*, *ip-address-range-2* with your own range.
50109

51-
First, create an IP allow rule for the policy created from the previous step. Note **--defer** is required because a rule must have a match condition to be added in the next step.
110+
First, create an IP allow rule for the policy created from the previous step.
111+
> [!NOTE]
112+
> **--defer** is required because a rule must have a match condition to be added in the next step.
52113
53114
```azurecli
54115
az network front-door waf-policy rule create \
@@ -138,7 +199,7 @@ $IPMatchCondition = New-AzFrontDoorWafMatchConditionObject `
138199

139200
Use the [New-AzFrontDoorWafCustomRuleObject](/powershell/module/Az.FrontDoor/New-azfrontdoorwafcustomruleobject) command to define an action and set a priority. In the following example, requests not from client IPs that match the list will be blocked.
140201

141-
```powershell
202+
```azurepowershell
142203
$IPAllowRule = New-AzFrontDoorWafCustomRuleObject `
143204
-Name "IPAllowRule" `
144205
-RuleType MatchRule `
@@ -149,7 +210,7 @@ $IPAllowRule = New-AzFrontDoorWafCustomRuleObject `
149210
### Configure a WAF policy
150211
Find the name of the resource group that contains the Azure Front Door profile by using `Get-AzResourceGroup`. Next, configure a WAF policy with the IP rule by using [New-AzFrontDoorWafPolicy](/powershell/module/az.frontdoor/new-azfrontdoorwafpolicy).
151212

152-
```powershell
213+
```azurepowershell
153214
$IPAllowPolicyExamplePS = New-AzFrontDoorWafPolicy `
154215
-Name "IPRestrictionExamplePS" `
155216
-resourceGroupName <resource-group-name> `
@@ -162,7 +223,7 @@ Find the name of the resource group that contains the Azure Front Door profile b
162223

163224
Link a WAF policy object to an existing front-end host and update Azure Front Door properties. First, retrieve the Azure Front Door object by using [Get-AzFrontDoor](/powershell/module/Az.FrontDoor/Get-AzFrontDoor). Next, set the **WebApplicationFirewallPolicyLink** property to the resource ID of *$IPAllowPolicyExamplePS*, created in the previous step, by using the [Set-AzFrontDoor](/powershell/module/Az.FrontDoor/Set-AzFrontDoor) command.
164225

165-
```powershell
226+
```azurepowershell
166227
$FrontDoorObjectExample = Get-AzFrontDoor `
167228
-ResourceGroupName <resource-group-name> `
168229
-Name $frontDoorName
39.1 KB
Loading
16.9 KB
Loading

0 commit comments

Comments
 (0)