Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Şunlar için geçerlidir: ✔️ Application Gateway v2
Azure Uygulama Ağ Geçidi üzerindeki Web Uygulaması Güvenlik Duvarı (WAF) v2, web uygulamaları için koruma sağlar. Bu koruma, Open Web Application Security Project (OWASP) Çekirdek Kural Kümesi (CRS) tarafından sağlanır. Bazı durumlarda, özel gereksinimlerinizi karşılamak için kendi özel kurallarınızı oluşturmanız gerekebilir. WAF özel kuralları hakkında daha fazla bilgi için bkz . Özel web uygulaması güvenlik duvarı kurallarına genel bakış.
Bu makalede, v2 WAF'nizle oluşturabileceğiniz ve kullanabileceğiniz bazı örnek özel kurallar gösterilmektedir. Azure PowerShell kullanarak özel bir kuralla WAF dağıtmayı öğrenmek için bkz. Azure PowerShell kullanarak Web Uygulaması Güvenlik Duvarı özel kuralları yapılandırma.
Bu makalede gösterilen JSON kod parçacıkları bir ApplicationGatewayWebApplicationFirewallPolicies kaynağından türetilmiştir.
Not
Uygulama ağ geçidiniz WAF katmanını kullanmıyorsa, sağ bölmede uygulama ağ geçidini WAF katmanına yükseltme seçeneği görüntülenir.
Örnek 1
Web sitenizde gezinmesini engellemek istediğiniz evilbot adlı bir bot olduğunu biliyorsunuz. Bu durumda, istek üst bilgilerinde User-Agent kötü botunu engellersiniz.
Mantık: p
$variable = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RequestHeaders `
-Selector User-Agent
$condition = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable `
-Operator Contains `
-MatchValue "evilbot" `
-Transform Lowercase `
-NegationCondition $False
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name blockEvilBot `
-Priority 2 `
-RuleType MatchRule `
-MatchCondition $condition `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "blockEvilBot",
"priority": 2,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RequestHeaders",
"selector": "User-Agent"
}
],
"operator": "Contains",
"negationCondition": false,
"matchValues": [
"evilbot"
],
"transforms": [
"Lowercase"
]
}
]
}
]
}
Bu özel kural kullanılarak dağıtılan bir WAF'yi görmek için bkz. Azure PowerShell kullanarak Web Uygulaması Güvenlik Duvarı özel kuralı yapılandırma.
Örnek 1a
Normal ifade kullanarak da aynı şeyi gerçekleştirebilirsiniz:
$variable = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RequestHeaders `
-Selector User-Agent
$condition = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable `
-Operator Regex `
-MatchValue "evilbot" `
-Transform Lowercase `
-NegationCondition $False
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name blockEvilBot `
-Priority 2 `
-RuleType MatchRule `
-MatchCondition $condition `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "blockEvilBot",
"priority": 2,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RequestHeaders",
"selector": "User-Agent"
}
],
"operator": "Regex",
"negationCondition": false,
"matchValues": [
"evilbot"
],
"transforms": [
"Lowercase"
]
}
]
}
]
}
Örnek 2
GeoMatch işlecini kullanarak yalnızca Birleşik Devletler gelen trafiğe izin vermek ve yönetilen kuralların geçerli olmasını istiyorsanız:
$variable = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RemoteAddr `
$condition = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable `
-Operator GeoMatch `
-MatchValue "US" `
-Transform Lowercase `
-NegationCondition $True
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name "allowUS" `
-Priority 2 `
-RuleType MatchRule `
-MatchCondition $condition `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "allowUS",
"priority": 2,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"operator": "GeoMatch",
"negationCondition": true,
"matchValues": [
"US"
],
"transforms": [
"Lowercase"
]
}
]
}
]
}
Örnek 3
198.168.5.0/24 aralığındaki IP adreslerinden gelen tüm istekleri engellemek istiyorsunuz.
Bu örnekte, bir IP adresleri aralığından gelen tüm trafiği engellersiniz. Kuralın adı myrule1 ve öncelik 10 olarak ayarlanır.
Mantık: p
$variable1 = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RemoteAddr
$condition1 = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable1 `
-Operator IPMatch `
-MatchValue "192.168.5.0/24" `
-NegationCondition $False
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name myrule1 `
-Priority 10 `
-RuleType MatchRule `
-MatchCondition $condition1 `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "myrule1",
"priority": 10,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"operator": "IPMatch",
"negationCondition": false,
"matchValues": [
"192.168.5.0/24"
],
"transforms": []
}
]
}
]
}
İlgili CRS kuralı: SecRule REMOTE_ADDR "@ipMatch 192.168.5.0/24" "id:7001,deny"
Örnek 4
Bu örnekte User-Agent kötü botunu ve 192.168.5.0/24 aralığındaki trafiği engellemek istiyorsunuz. Bu eylemi gerçekleştirmek için iki ayrı eşleştirme koşulu oluşturabilir ve ikisini de aynı kurala yerleştirebilirsiniz. Bu yapılandırma, User-Agent üst bilgisindeki kötü botun ve 192.168.5.0/24 aralığındaki IP adreslerinin eşleştirilmesini sağlar ve istek engellenir.
Mantık: p ve q
$variable1 = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RemoteAddr
$variable2 = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RequestHeaders `
-Selector User-Agent
$condition1 = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable1 `
-Operator IPMatch `
-MatchValue "192.168.5.0/24" `
-NegationCondition $False
$condition2 = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable2 `
-Operator Contains `
-MatchValue "evilbot" `
-Transform Lowercase `
-NegationCondition $False
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name myrule `
-Priority 10 `
-RuleType MatchRule `
-MatchCondition $condition1, $condition2 `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "myrule",
"priority": 10,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"operator": "IPMatch",
"negationCondition": false,
"matchValues": [
"192.168.5.0/24"
],
"transforms": []
},
{
"matchVariables": [
{
"variableName": "RequestHeaders",
"selector": "User-Agent"
}
],
"operator": "Contains",
"negationCondition": false,
"matchValues": [
"evilbot"
],
"transforms": [
"Lowercase"
]
}
]
}
]
}
Örnek 5
Bu örnekte, istek 192.168.5.0/24 IP adresi aralığının dışındaysa veya kullanıcı aracısı dizesi chrome değilse (kullanıcının Chrome tarayıcısını kullanmadığından) engellemek istiyorsunuz. Bu mantık "veya" kullandığından, aşağıdaki örnekte görüldüğü gibi iki koşul ayrı kurallardadır. myrule1 ve myrule2'nin trafiği engellemek için eşleşmesi gerekir.
Mantık: not (p ve q) = p değil veya q değil.
$variable1 = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RemoteAddr
$variable2 = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RequestHeaders `
-Selector User-Agent
$condition1 = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable1 `
-Operator IPMatch `
-MatchValue "192.168.5.0/24" `
-NegationCondition $True
$condition2 = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable2 `
-Operator Contains `
-MatchValue "chrome" `
-Transform Lowercase `
-NegationCondition $True
$rule1 = New-AzApplicationGatewayFirewallCustomRule `
-Name myrule1 `
-Priority 10 `
-RuleType MatchRule `
-MatchCondition $condition1 `
-Action Block `
-State Enabled
$rule2 = New-AzApplicationGatewayFirewallCustomRule `
-Name myrule2 `
-Priority 20 `
-RuleType MatchRule `
-MatchCondition $condition2 `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "myrule1",
"priority": 10,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"operator": "IPMatch",
"negationCondition": true,
"matchValues": [
"192.168.5.0/24"
],
"transforms": []
}
]
},
{
"name": "myrule2",
"priority": 20,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RequestHeaders",
"selector": "User-Agent"
}
],
"operator": "Contains",
"negationCondition": true,
"matchValues": [
"chrome"
],
"transforms": [
"Lowercase"
]
}
]
}
]
}
Örnek 6
Yalnızca belirli bilinen kullanıcı aracılarından gelen isteklere izin vermek ve kullanıcı aracısının mevcut olmadığı istekleri engellemek istiyorsunuz. Bu senaryo için iki özel kural oluşturmanız gerekir; kullanıcı aracısının eksik olduğu istekleri engellemek için bir tane ve yetkisiz kullanıcı aracısı olan istekleri engellemek için ikinci bir kural.
Kural 1
$variable = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RequestHeaders `
-Selector User-Agent
$condition = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable `
-Operator Any `
-NegationCondition $True
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name BlockMissingUserAgents `
-Priority 1 `
-RuleType MatchRule `
-MatchCondition $condition `
-Action Block `
-State Enabled
İlgili JSON:
[
{
"name": "BlockMissingUserAgents",
"priority": 1,
"ruleType": "MatchRule",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RequestHeaders",
"selector": "User-Agent"
}
],
"operator": "Any",
"negationConditon": true,
"matchValues": [
".*"
],
"transforms": []
}
],
"action": "Block",
"state": "Enabled"
},
Kural 2
Burada kullanılan mantık veya ve tüm değerler User-Agent üst bilgisinde yer aldığından, tüm MatchValues virgülle ayrılmış bir listede olabilir.
Mantık: p veya q veya r
$variable = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RequestHeaders `
-Selector User-Agent
$condition = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable `
-Operator Equal `
-MatchValue @('user1', 'user2') `
-NegationCondition $True
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name BlockUnknownUserAgents `
-Priority 2 `
-RuleType MatchRule `
-MatchCondition $condition `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "BlockUnknownUserAgents",
"priority": 2,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RequestHeaders",
"selector": "User-Agent"
}
],
"operator": "Equal",
"negationCondition": true,
"matchValues": [
"user1",
"user2"
],
"transforms": []
}
]
}
]
}
Örnek 7
Azure Front Door'un Application Gateway'in önünde dağıtılması sık karşılaşılan bir durumdur. Application Gateway tarafından alınan trafiğin Front Door dağıtımından geldiğinden emin olmak için en iyi yöntem üst bilginin beklenen benzersiz değeri içerip içermediğini X-Azure-FDID denetlemektir. Azure Front Door kullanarak uygulamanıza erişimi güvenli hale getirme hakkında daha fazla bilgi için bkz . Arka ucuma erişimi yalnızca Azure Front Door'a kilitleme
Mantık: p değil
$expectedFDID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
$variable = New-AzApplicationGatewayFirewallMatchVariable `
-VariableName RequestHeaders `
-Selector X-Azure-FDID
$condition = New-AzApplicationGatewayFirewallCondition `
-MatchVariable $variable `
-Operator Equal `
-MatchValue $expectedFDID `
-Transform Lowercase `
-NegationCondition $True
$rule = New-AzApplicationGatewayFirewallCustomRule `
-Name blockNonAFDTraffic `
-Priority 2 `
-RuleType MatchRule `
-MatchCondition $condition `
-Action Block `
-State Enabled
İlgili JSON:
{
"customRules": [
{
"name": "blockNonAFDTraffic",
"priority": 2,
"ruleType": "MatchRule",
"action": "Block",
"state": "Enabled",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RequestHeaders",
"selector": "X-Azure-FDID"
}
],
"operator": "Equal",
"negationCondition": true,
"matchValues": [
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
],
"transforms": [
"Lowercase"
]
}
]
}
]
}
Sonraki adım
Özel kurallarınızı oluşturduktan sonra WAF günlüklerinizi görüntülemeyi öğrenebilirsiniz. Daha fazla bilgi için bkz. Application Gateway tanılama.