Skip to content

Commit c574e48

Browse files
authored
Merge pull request #90396 from itechedit/application-gateway
edit pass: application-gateway
2 parents d722370 + e316056 commit c574e48

File tree

3 files changed

+113
-95
lines changed

3 files changed

+113
-95
lines changed

articles/application-gateway/configure-waf-custom-rules.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Configure Web Application Firewall v2 custom rules using Azure PowerShell
3-
description: Learn how to configure WAF v2 custom rules using Azure PowerShell
2+
title: Configure web application firewall v2 custom rules by using Azure PowerShell
3+
description: Learn how to configure web application firewall v2 custom rules by using Azure PowerShell
44
services: application-gateway
55
author: vhorne
66
ms.service: application-gateway
@@ -9,33 +9,32 @@ ms.date: 6/18/2019
99
ms.author: victorh
1010
---
1111

12-
# Configure Web Application Firewall v2 with a custom rule using Azure PowerShell
12+
# Configure web application firewall v2 custom rules by using Azure PowerShell
1313

1414
<!--- If you make any changes to the PowerShell in this article, also make the change in the corresponding Sample file: azure-docs-powershell-samples/application-gateway/waf-rules/waf-custom-rules.ps1 --->
1515

16-
Custom rules allow you to create your own rules evaluated for each request that passes through the Web Application Firewall (WAF) v2. These rules hold a higher priority than the rest of the rules in the managed rule sets. The custom rules have an action (to allow or block), a match condition, and an operator to allow full customization.
16+
With custom rules, you can create your own rules, which are evaluated for each request that passes through the web application firewall (WAF). These rules hold a higher priority than the rest of the rules in the managed rule sets. To allow full customization, the custom rules have an action (to allow or block), a match condition, and an operator.
1717

18-
This article creates an Application Gateway WAF v2 that uses a custom rule. The custom rule blocks traffic if the request header contains User-Agent *evilbot*.
18+
This article creates an Azure Application Gateway WAF v2 that uses a custom rule. The custom rule blocks traffic if the request header contains User-Agent *evilbot*.
1919

20-
To see more custom rule examples, see [Create and use custom web application firewall rules](create-custom-waf-rules.md)
20+
To view more custom rule examples, see [Create and use custom web application firewall rules](create-custom-waf-rules.md).
2121

22-
If you want run the Azure PowerShell in this article in one continuous script that you can copy, paste, and run, see [Azure Application Gateway PowerShell samples](powershell-samples.md).
22+
To run the Azure PowerShell code in this article in one continuous script that you can copy, paste, and run, see [Azure Application Gateway PowerShell samples](powershell-samples.md).
2323

2424
## Prerequisites
25+
* [!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
2526

26-
### Azure PowerShell module
27+
* You need an Azure PowerShell module. If you choose to install and use Azure PowerShell locally, this script requires Azure PowerShell module version 2.1.0 or later. Do the following:
2728

28-
If you choose to install and use Azure PowerShell locally, this script requires the Azure PowerShell module version 2.1.0 or later.
29-
30-
1. To find the version, run `Get-Module -ListAvailable Az`. If you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-az-ps).
31-
2. To create a connection with Azure, run `Connect-AzAccount`.
32-
33-
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
29+
1. To find the version, run `Get-Module -ListAvailable Az`. If you need to upgrade, see [Install Azure PowerShell module](/powershell/azure/install-az-ps).
30+
2. To create a connection with Azure, run `Connect-AzAccount`.
3431

3532
## Example script
3633

3734
### Set up variables
3835

36+
Run the following code:
37+
3938
```azurepowershell
4039
$rgname = "CustomRulesTest"
4140
@@ -46,11 +45,15 @@ $appgwName = "WAFCustomRules"
4645

4746
### Create a resource group
4847

48+
Run the following code:
49+
4950
```azurepowershell
5051
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location
5152
```
5253

53-
### Create a VNet
54+
### Create a virtual network
55+
56+
Run the following code:
5457

5558
```azurepowershell
5659
$sub1 = New-AzVirtualNetworkSubnetConfig -Name "appgwSubnet" -AddressPrefix "10.0.0.0/24"
@@ -61,14 +64,18 @@ $vnet = New-AzvirtualNetwork -Name "Vnet1" -ResourceGroupName $rgname -Location
6164
-AddressPrefix "10.0.0.0/16" -Subnet @($sub1, $sub2)
6265
```
6366

64-
### Create a Static Public VIP
67+
### Create a static public VIP
68+
69+
Run the following code:
6570

6671
```azurepowershell
6772
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name "AppGwIP" `
6873
-location $location -AllocationMethod Static -Sku Standard
6974
```
7075

71-
### Create pool and frontend port
76+
### Create a pool and front-end port
77+
78+
Run the following code:
7279

7380
```azurepowershell
7481
$gwSubnet = Get-AzVirtualNetworkSubnetConfig -Name "appgwSubnet" -VirtualNetwork $vnet
@@ -83,7 +90,9 @@ $pool = New-AzApplicationGatewayBackendAddressPool -Name "pool1" `
8390
$fp01 = New-AzApplicationGatewayFrontendPort -Name "port1" -Port 80
8491
```
8592

86-
### Create a listener, http setting, rule, and autoscale
93+
### Create a listener, HTTP setting, rule, and autoscale
94+
95+
Run the following code:
8796

8897
```azurepowershell
8998
$listener01 = New-AzApplicationGatewayHttpListener -Name "listener1" -Protocol Http `
@@ -102,6 +111,8 @@ $sku = New-AzApplicationGatewaySku -Name WAF_v2 -Tier WAF_v2
102111

103112
### Create the custom rule and apply it to WAF policy
104113

114+
Run the following code:
115+
105116
```azurepowershell
106117
$variable = New-AzApplicationGatewayFirewallMatchVariable -VariableName RequestHeaders -Selector User-Agent
107118
@@ -114,7 +125,9 @@ $wafPolicy = New-AzApplicationGatewayFirewallPolicy -Name wafPolicy -ResourceGro
114125
$wafConfig = New-AzApplicationGatewayWebApplicationFirewallConfiguration -Enabled $true -FirewallMode "Prevention"
115126
```
116127

117-
### Create the Application Gateway
128+
### Create an application gateway
129+
130+
Run the following code:
118131

119132
```azurepowershell
120133
$appgw = New-AzApplicationGateway -Name $appgwName -ResourceGroupName $rgname `
@@ -129,4 +142,4 @@ $appgw = New-AzApplicationGateway -Name $appgwName -ResourceGroupName $rgname `
129142

130143
## Next steps
131144

132-
[Learn more about Web Application Firewall](waf-overview.md)
145+
[Learn more about web application firewall](waf-overview.md)

articles/application-gateway/create-custom-waf-rules.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Create and use Azure Web Application Firewall (WAF) v2 custom rules
3-
description: This article provides information on how to create Web Application Firewall (WAF) v2 custom rules in Azure Application Gateway.
2+
title: Create and use Azure web application firewall (WAF) v2 custom rules
3+
description: This article discusses how to create web application firewall (WAF) v2 custom rules in Azure Application Gateway.
44
services: application-gateway
55
ms.topic: article
66
author: vhorne
@@ -9,20 +9,20 @@ ms.date: 6/18/2019
99
ms.author: victorh
1010
---
1111

12-
# Create and use Web Application Firewall v2 custom rules
12+
# Create and use web application firewall v2 custom rules
1313

14-
The Azure Application Gateway Web Application Firewall (WAF) v2 provides protection for web applications. This protection is provided by the Open Web Application Security Project (OWASP) Core Rule Set (CRS). In some cases, you may need to create your own custom rules to meet your specific needs. For more information about WAF custom rules, see [Custom web application firewall rules overview](custom-waf-rules-overview.md).
14+
Azure Application Gateway web application firewall (WAF) v2 provides protection for web applications. This protection is provided by the Open Web Application Security Project (OWASP) core rule set. In some cases, you might need to create your own custom rules to meet your specific needs. For more information about WAF custom rules, see [Overview: Custom web application firewall rules](custom-waf-rules-overview.md).
1515

16-
This article shows you some example custom rules that you can create and use with your v2 WAF. To learn how to deploy a WAF with a custom rule using Azure PowerShell, see [Configure Web Application Firewall custom rules using Azure PowerShell](configure-waf-custom-rules.md).
16+
This article shows you some example custom rules that you can create and use with WAF v2. To learn how to deploy WAF with a custom rule by using Azure PowerShell, see [Configure web application firewall custom rules by using Azure PowerShell](configure-waf-custom-rules.md).
1717

18-
>[!NOTE]
19-
> If your application gateway is not using the WAF tier, the option to upgrade the application gateway to the WAF tier appears in the right pane.
18+
> [!NOTE]
19+
> If your application gateway isn't using the WAF tier, the option to upgrade the application gateway to the WAF tier appears in the right pane.
2020
2121
![Enable WAF][fig1]
2222

2323
## Example 1
2424

25-
You know there's a bot named *evilbot* that you want to block from crawling your website. In this case, you’ll block on the User-Agent *evilbot* in the request headers.
25+
You know there's a bot named *evilbot* that you want to block from crawling your website. In this example, you block the User-Agent *evilbot* in the request headers.
2626

2727
Logic: p
2828

@@ -46,7 +46,7 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
4646
-Action Block
4747
```
4848

49-
And here is the corresponding JSON:
49+
Here's the corresponding JSON code:
5050

5151
```json
5252
{
@@ -70,11 +70,11 @@ And here is the corresponding JSON:
7070
}
7171
```
7272

73-
To see a WAF deployed using this custom rule, see [Configure a Web Application Firewall custom rule using Azure PowerShell](configure-waf-custom-rules.md).
73+
To view a WAF that's deployed by using this custom rule, see [Configure a web application firewall custom rule by using Azure PowerShell](configure-waf-custom-rules.md).
7474

7575
### Example 1a
7676

77-
You can accomplish the same thing using a regular expression:
77+
You can accomplish the same thing by using a regular expression:
7878

7979
```azurepowershell
8080
$variable = New-AzApplicationGatewayFirewallMatchVariable `
@@ -96,7 +96,7 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
9696
-Action Block
9797
```
9898

99-
And the corresponding JSON:
99+
Here's the corresponding JSON code:
100100

101101
```json
102102
{
@@ -124,7 +124,7 @@ And the corresponding JSON:
124124

125125
You want to block all requests from IP addresses in the range 198.168.5.0/24.
126126

127-
In this example, you'll block all traffic that comes from an IP addresses range. The name of the rule is *myrule1* and the priority is set to 100.
127+
In this example, you block all traffic that comes from a range of IP addresses. The name of the rule is *myrule1*, and the priority is set to 100.
128128

129129
Logic: p
130130

@@ -146,7 +146,7 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
146146
-Action Block
147147
```
148148

149-
Here's the corresponding JSON:
149+
Here's the corresponding JSON code:
150150

151151
```json
152152
{
@@ -170,14 +170,15 @@ Here's the corresponding JSON:
170170
}
171171
```
172172

173-
Corresponding CRS rule:
173+
Here's the corresponding core rule set rule:
174+
174175
`SecRule REMOTE_ADDR "@ipMatch 192.168.5.0/24" "id:7001,deny"`
175176

176177
## Example 3
177178

178-
For this example, you want to block User-Agent *evilbot*, and traffic in the range 192.168.5.0/24. To accomplish this, you can create two separate match conditions, and put them both in the same rule. This ensures that if both *evilbot* in the User-Agent header **and** IP addresses from the range 192.168.5.0/24 are matched, then the request is blocked.
179+
For this example, you want to block User-Agent *evilbot*, and traffic in the range 192.168.5.0/24. To achieve this result, you can create two separate match conditions and put them both in the same rule. This approach ensures that if both *evilbot* in the User-Agent header *and* IP addresses from the range 192.168.5.0/24 are matched, the request is blocked.
179180

180-
Logic: p **and** q
181+
Logic: p *and* q
181182

182183
```azurepowershell
183184
$variable1 = New-AzApplicationGatewayFirewallMatchVariable `
@@ -208,7 +209,7 @@ $condition2 = New-AzApplicationGatewayFirewallCondition `
208209
-Action Block
209210
```
210211

211-
Here's the corresponding JSON:
212+
Here's the corresponding JSON code:
212213

213214
```json
214215
{
@@ -247,9 +248,9 @@ Here's the corresponding JSON:
247248

248249
## Example 4
249250

250-
For this example, you want to block if the request is either outside of the IP address range *192.168.5.0/24*, or the user agent string isn't *chrome* (meaning the user isn’t using the Chrome browser). Since this logic uses **or**, the two conditions are in separate rules as seen in the following example. *myrule1* and *myrule2* both need to match to block the traffic.
251+
For this example, you want to block if the request is either outside of the IP address range *192.168.5.0/24*, or the user agent string isn't *chrome* (that is, the user isn’t using the Chrome browser). Because this logic uses *or*, the two conditions are in separate rules, as shown in the following example. To block the traffic, both *myrule1* and *myrule2* need to match.
251252

252-
Logic: **not** (p **and** q) = **not** p **or not** q.
253+
Logic: *not* (p *and* q) = *not* p *or not* q.
253254

254255
```azurepowershell
255256
$variable1 = New-AzApplicationGatewayFirewallMatchVariable `
@@ -287,7 +288,7 @@ $rule2 = New-AzApplicationGatewayFirewallCustomRule `
287288
-Action Block
288289
```
289290

290-
And the corresponding JSON:
291+
Here's the corresponding JSON code:
291292

292293
```json
293294
{
@@ -334,9 +335,9 @@ And the corresponding JSON:
334335

335336
## Example 5
336337

337-
You want to block custom SQLI. Since the logic used here is **or**, and all the values are in the *RequestUri*, all of the *MatchValues* can be in a comma-separated list.
338+
You want to block custom SQLI. Because the logic used here is *or* and all the values are in the *RequestUri*, all the *MatchValues* can be in a comma-separated list.
338339

339-
Logic: p **or** q **or** r
340+
Logic: p *or* q *or* r
340341

341342
```azurepowershell
342343
$variable1 = New-AzApplicationGatewayFirewallMatchVariable `
@@ -355,7 +356,7 @@ $rule1 = New-AzApplicationGatewayFirewallCustomRule `
355356
-Action Block
356357
```
357358

358-
Corresponding JSON:
359+
Here's the corresponding JSON code:
359360

360361
```json
361362
{
@@ -381,7 +382,7 @@ Corresponding JSON:
381382
}
382383
```
383384

384-
Alternative Azure PowerShell:
385+
Here's the alternative Azure PowerShell code:
385386

386387
```azurepowershell
387388
$variable1 = New-AzApplicationGatewayFirewallMatchVariable `
@@ -432,7 +433,7 @@ $rule3 = New-AzApplicationGatewayFirewallCustomRule `
432433
-Action Block
433434
```
434435

435-
Corresponding JSON:
436+
Here's the corresponding JSON code:
436437

437438
```json
438439
{

0 commit comments

Comments
 (0)