Skip to content

Instantly share code, notes, and snippets.

@soderlind
Last active September 19, 2024 10:40
Show Gist options
  • Save soderlind/38ba10db6603db449c7f4a9333491c41 to your computer and use it in GitHub Desktop.
Save soderlind/38ba10db6603db449c7f4a9333491c41 to your computer and use it in GitHub Desktop.
WordPress: Use Azure Front Door to rate limit access the login page
resource wafPolicy 'Microsoft.Network/FrontDoorWebApplicationFirewallPolicies@2022-05-01' = {
name: wafPolicyName
location: 'global'
sku: {
name: frontDoorSkuName
}
tags: tags
properties: {
policySettings: {
enabledState: 'Enabled'
mode: wafMode
customBlockResponseStatusCode: 429
}
customRules: {
rules: [
{
name: 'RateLimitOthers'
priority: 1
ruleType: 'RateLimitRule'
matchConditions: [
{
matchVariable: 'RemoteAddr'
operator: 'GeoMatch'
negateCondition: true // Don't match the matchValue
matchValue: [
'NO' // ISO country code for Norway
]
}
{
matchVariable: 'RequestUri'
operator: 'BeginsWith'
matchValue: [
'/wp-login.php'
]
}
]
action: 'Block'
rateLimitThreshold: 5 // Set your rate limit threshold
rateLimitDurationInMinutes: 1 // Set your rate limit duration
}
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment