You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 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.
15
15
16
16
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.
17
17
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:
> 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.
19
78
20
79
## Configure a WAF policy with the Azure CLI
21
80
@@ -48,7 +107,9 @@ In the following examples:
48
107
- Replace *IPAllowPolicyExampleCLI* with your unique policy created earlier.
49
108
- Replace *ip-address-range-1*, *ip-address-range-2* with your own range.
50
109
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.
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.
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).
@@ -162,7 +223,7 @@ Find the name of the resource group that contains the Azure Front Door profile b
162
223
163
224
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.
0 commit comments