How secure are your web applications? Deploy an Azure Application Gateway with Web Application Firewall (WAF). This is a powerful tool to protect your applications while ensuring seamless performance. Let’s dive in and explore how you can get started!
Why deploy an Application Gateway?
Have you ever heard about the OWASP Top 10? It is a list of the most common web application security risks. Could you even name all ten risks? If not, you are not alone. But you want to protect against these risks, right? An Application Gateway with Web Application Firewall (WAF) can help you with that. It is a managed service that provides a web application firewall to protect your web applications from common threats and vulnerabilities.
Alternatives
An alternative is using the Azure FrontDoor service. Or look outside of Azure, but I will not discuss those options in this blog. Frontdoor has some additional features like CDN and global load balancing.
How to migrate to an Application Gateway?
Let’s say you have a web application running on Azure App Service. You want to migrate this application to use an Application Gateway with WAF. Here are the steps you need to take:
- Create a Key Vault to store the SSL/TLS certificates.
- Create a Vnet and subnet for the Application Gateway.
- Create a Public IP Address for the Application Gateway.
- Create a new Application Gateway with WAF enabled.
- Configure the backend pool to point to your Azure App Service.
- Create a new routing rule to forward traffic to the backend pool.
- Update your DNS settings to point to the Application Gateway.
I assume you have a Key Vault and know how to provide it with an SSL/TLS certificate. Let’s combine the 2,3, 4, and 5 steps in a Bicep deployment.
Deploy Application gateway using bicep
Let’s deploy an Application Gateway with a backend pool pointing to an Azure App Service.
|  |  | 
Configure DNS for Application Gateway
After deploying the Application Gateway, you need to update your DNS settings to point to the Application Gateway’s public IP address. This ensures that all incoming traffic to your web application is routed through the Application Gateway, allowing it to provide the necessary security and performance enhancements.
Detection vs Prevention mode
When configuring the WAF policy, you have the option to set the mode to either “Detection” or “Prevention”. In Detection mode, the WAF will monitor and log potential threats without blocking any traffic. This is useful for testing and tuning the WAF rules before enforcing them. In Prevention mode, the WAF will actively block traffic that matches the defined rules, providing a higher level of security for your web applications.
I recommend starting with Detection mode to understand the traffic patterns and potential threats to your application. Once you are confident that the WAF rules are properly configured, you can switch to Prevention mode for enhanced protection.
See my next blog post on how to find false positives and tune your WAF rules.
Next steps
We now got an Application gateway before your application. Your next steps could be:
- Configure custom WAF rules to tailor the security settings to your specific application needs.
- Set up monitoring and alerting to keep an eye on the WAF logs and performance metrics. ( see WAF monitoring)
- If you see no false positives you can switch from Detection to Prevention mode. (see Troubleshoot Application Gateway in Production)
- Implement ip restrictions for your Application gateway on Staging or acceptance environments. (see Implement IP Restrictions)
- Learn more about ipv6. (see Application Gateway with IPv6 support).
