Azure Application Gateway WAF

The Azure Web Application Firewall (WAF) on Azure Application Gateway provides centralized web application protection against common exploits and vulnerabilities. It helps protect your web applications from threats such as SQL injection, cross-site scripting, and other common web attacks.

Note: WAF on Application Gateway is a feature that requires a compatible SKU. Ensure you are using the appropriate SKU for WAF functionality.

What is WAF?

A Web Application Firewall (WAF) is a security solution that monitors, filters, and blocks HTTP/S traffic to and from a web application. It operates at the application layer (Layer 7) and can detect and prevent malicious HTTP/S requests and responses.

Key Features of Azure WAF

WAF Policies

A WAF policy is a collection of rules and configurations that define how the WAF protects your web applications. You can create different WAF policies and associate them with your Application Gateway instances.

Creating a WAF Policy

You can create a WAF policy through the Azure portal, Azure CLI, or Azure PowerShell.

Using Azure CLI:


az network application-gateway waf-policy create \
    --name MyWAFPolicy \
    --resource-group MyResourceGroup \
    --location eastus \
    --sku Premium_WAF
            

WAF Modes

Azure WAF can operate in two modes:

OWASP Rule Sets

Azure WAF supports two versions of the OWASP core rule set:

Tip: It is recommended to use the latest OWASP rule set version (3.1) for maximum protection. You can choose to enable or disable specific rules within a managed rule set to fine-tune your WAF configuration.

Custom Rules Example

You can create custom rules to match specific patterns in requests. For example, to block requests with a specific User-Agent header:


az network application-gateway waf-policy rule create \
    --policy-name MyWAFPolicy \
    --resource-group MyResourceGroup \
    --name BlockBadUserAgent \
    --type Custom \
    --action Block \
    --match-conditions operator='Equal' matchValue='BadBot/1.0' \
        matchVariable='RequestHeader' selector='User-Agent' \
    --priority 100
            

Monitoring WAF Activity

To effectively manage your WAF, it's crucial to monitor its activity. You can access WAF logs and metrics through Azure Monitor.

Key metrics to monitor include:

Azure WAF Dashboard Example

Best Practices

For more detailed information, please refer to the official Azure Application Gateway WAF documentation.