
myrule1 and myrule2 both need to match to block the traffic. Since this logic uses or, the two conditions are in separate rules as seen in the following example. MatchCondition $condition1, $condition2 `įor 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). $condition2 = New-AzApplicationGatewayFirewallCondition `

$variable2 = New-AzApplicationGatewayFirewallMatchVariable ` Logic: p and q $variable1 = New-AzApplicationGatewayFirewallMatchVariable ` 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. To accomplish this, you can create two separate match conditions, and put them both in the same rule. SecRule REMOTE_ADDR 192.168.5.0/24" "id:7001,deny" Example 4įor this example, you want to block User-Agent evilbot, and traffic in the range 192.168.5.0/24. $condition1 = New-AzApplicationGatewayFirewallCondition ` Logic: p $variable1 = New-AzApplicationGatewayFirewallMatchVariable ` The name of the rule is myrule1 and the priority is set to 10. In this example, you'll block all traffic that comes from an IP addresses range.

You want to block all requests from IP addresses in the range 198.168.5.0/24. You want to allow traffic only from the US using the GeoMatch operator and still have the managed rules apply: $variable = New-AzApplicationGatewayFirewallMatchVariable ` You can accomplish the same thing using a regular expression: $variable = New-AzApplicationGatewayFirewallMatchVariable ` To see a WAF deployed using this custom rule, see Configure a Web Application Firewall custom rule using Azure PowerShell. $rule = New-AzApplicationGatewayFirewallCustomRule ` $condition = New-AzApplicationGatewayFirewallCondition ` Logic: p $variable = New-AzApplicationGatewayFirewallMatchVariable ` In this case, you’ll block on the User-Agent evilbot in the request headers. You know there's a bot named evilbot that you want to block from crawling your website.

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.
