Load Balancing & Delivery参照資料確認: 2026-09-11

WAF for Application Gateway

Application Gateway WAF_v2を、WAF Policy、custom/managed rules、Detection/Prevention、anomaly scoring、exclusion運用まで整理する。

この記事の目次

WAF for Application Gatewayを理解するための前提

Application Gateway WAF_v2ではWAF Policyにcustom rules、managed rules、exclusions等をまとめ、gateway/listener/pathへassociationできる。 policyはglobal、per-site(listener)、per-URI(path-based rule)のscopeで分離できる。

custom ruleはmanaged ruleより先に評価されるため、Allow等の例外がmanaged protectionをbypassし得る。 Detection modeは観測・tuning、Prevention modeはblockを伴う。production切替前にfalse positiveをWAF logで確認する。

managed rule disableを第一手にせず、request attribute exclusionやnarrow custom ruleなど最小scopeで調整する。 WAF blockはbackend application 403と区別し、WAF logのrule ID/action/matched variableを証拠にする。

通信や判断の流れを追う
ClientEdge / Load balancerRouting / HealthBackend

Control plane / Data plane / Observability

Policy scope

gateway / listener / pathで適用範囲を定義。

Rule evaluation

custom rule→managed ruleの順序を理解。

Operations

Detectionで観測し、最小exclusion後にPreventionへ。

判定原則L4 flow、L7 proxy、DNS steering、NVA chainingを同じ「load balancing」として扱わず、clientが最終的にどのIPへ接続し、どこでconnectionが終端/再生成されるかを最初に固定します。

Client-to-backend path

  1. client requestがWAF_v2 listenerへ到達する。
  2. 適用WAF Policyとcustom rulesをpriority順に評価する。
  3. managed rule setがrequest componentをinspection/anomaly scoringする。
  4. Detectionならlog、Preventionならpolicy/actionに従ってblock等を実行する。
  5. 許可requestだけrouting rule/backendへ進む。
  6. WAF/access/backend logを同じrequest contextで相関する。

仕組みを分解する

WAF tuningは「rule 949110がblockしたから949110をdisable」では不十分です。anomaly scoringでは個別match rulesの合計でblocking thresholdに達します。実際にmatchedしたrule IDとvariableを確認し、正当requestの特定fieldだけをexclusionする方がblast radiusを小さくできます。

運用時はresource configurationだけで完了判定せず、実clientからの名前解決、TCP/TLS handshake、HTTP status、backend側のsource IP/Host/header、health telemetryを同じtimestampで揃えます。load balancer/proxyがhealthyでもapplication dependencyが壊れている場合があり、逆にbackend applicationが正常でもhealth probe条件やrouting ruleが不整合ならtrafficは到達しません。

設計判断

判断軸設計方針
Policy granularity複数siteを1 gatewayに載せる場合、security profileが違えばlistener/path policyへ分ける。
Mode rolloutDetection→log review→exclusion/custom tuning→Preventionの段階移行を基本にする。
Managed rulesversion変更はreleaseとして扱い、before/after false positive/coverageを比較する。
LoggingWAF logsをLog Analytics等へ常時送信し、block理由を再現できるようにする。

確認手順

Read-only verification

  • WAF policy association scopeをgateway/listener/pathごとに確認する。
  • mode、managed rule set/version、custom rule priority/action、exclusionをexportする。
  • known benign/malicious test requestでDetection/Prevention behaviorを確認する。
  • WAF logのruleId/message/detailsとapplication access logを相関する。

Evidence to keep

  • resource ID / subscription / region / frontend / backend targetを保存し、同名resource取り違えを防ぐ。
  • DNS answer、source IP、destination IP/port、Host/SNI、health status、timestampを同じincident recordへ残す。
  • 変更前後で同じclient journeyをnew connectionとして再実行する。
  • Portal表示だけでなくCLI/PowerShell/APIまたはlogsを併用し、観測面の一時差を識別する。
Azure CLI — read-only first
az network application-gateway waf-policy show -g <rg> -n <policy> -o jsonc
az network application-gateway show -g <rg> -n <appgw> --query "firewallPolicy.id" -o tsv
PowerShell — read-only first
Get-AzApplicationGatewayFirewallPolicy -ResourceGroupName <rg> -Name <policy> | Format-List *

障害切り分け

症状第一候補証拠次の確認
正当request 403false positiveWAF log rule ID/variablenarrow exclusion
悪性requestが通るDetection/Allow rulepolicy mode/custom priorityPrevention + rule order
siteごと挙動違うpolicy association scopelistener/path policy IDseffective policy確認
大量blockruleset update/app changetime-series rule IDchange correlation
backend logなしedgeでWAF blockWAF access logbackend前blockと判定

変更時の確認と rollback

  • WAF Policy JSONをversion controlする。
  • managed ruleset upgradeは旧versionへ戻せるrelease単位にする。
  • exclusionはowner/reason/expiryを記録する。
  • Prevention→Detection rollback後もalertingを維持し、単なる無防備化にしない。
Change safety: health probe、DNS、TLS certificate、WAF/routing rule、backend poolを同時に変えるとfailure domainを判別できません。1 hypothesisずつ変更し、各段階で同じobservable journeyを再実行します。

Current notes — 2026-09-11

Current behavior / guidance

WAF_v2ではpolicyをgateway/listener/pathにassociationでき、custom rulesとmanaged rules/exclusionsをscope別に運用できる。

Official sources

動作、retirement、feature availability、health/TLS behaviorはMicrosoft Learnのcurrent documentationを基準に確認しています。production変更時は対象subscription/region/SKUの最新documentationとresource provider stateを再確認してください。