- What is a web application firewall?A WAF sits between visitors and a web application and examines each HTTP request.
- How is a WAF different from a normal firewall?You need both.
- What does a WAF protect against?Injection attacks such as SQL injection.
What is a web application firewall?
A WAF sits between visitors and a web application and examines each HTTP request. It compares requests to rules and blocks, challenges or logs the ones that look like attacks. OWASP describes a WAF as a filter that applies a set of rules to a conversation between a client and a web application, covering attacks such as cross-site scripting and SQL injection.
A WAF understands web traffic, unlike a traditional network firewall that decides by address and port. It can notice that a request to a login page contains a database command, or that a bot is trying thousands of passwords.
How is a WAF different from a normal firewall?
You need both. The server firewall is covered in how to secure a new VPS.
| Network firewall | Web application firewall | |
|---|---|---|
| Looks at | IP addresses, ports, protocols | The content of HTTP requests |
| Stops | Unwanted connections | Malicious requests to your site |
| Example rule | Allow only ports 80, 443 and 22 | Block requests with SQL syntax in a form field |
| Where it lives | Server or network edge | In front of the site: a CDN, a proxy, the server or a plugin |
What does a WAF protect against?
- Injection attacks such as SQL injection.
- Cross-site scripting.
- Brute-force logins and credential stuffing.
- Scrapers and abusive bots.
- Known exploits against popular CMS plugins, using virtual patches until you can update.
- Some application-layer floods, which overlaps with [DDoS protection](/guides/what-is-ddos-protection/).
Where can you get a WAF?
| Option | How it works | Notes |
|---|---|---|
| CDN or reverse proxy | Traffic passes through the provider first | Common and easy; see what a CDN is |
| Host-provided | Built into the hosting platform | Often included on managed WordPress plans |
| Server module | Software on your own server | Needs setup and tuning |
| Plugin | Runs inside your application, such as a WordPress security plugin | Uses your server’s resources |
Does a WAF slow your site down?
A cloud WAF adds a small processing step, but because it usually comes with a CDN and caching, most sites get faster overall. A plugin or server module uses your own CPU, which matters on small plans. Measure before and after using the method in what TTFB is.
What about false positives?
Rules can block legitimate requests, for example a form that contains code in a post, or an API client that looks like a bot. Start in log-only mode if the product supports it, review what would have been blocked and then enforce. Keep a way to whitelist a path or an IP address, and test your forms, checkout and admin pages after any rule change. Check logs after you turn it on; blocked real customers are lost sales.
Do you need a WAF?
Most public sites benefit, especially those with logins, forms and shops, and sites that run many plugins. Treat it as one layer. Update your software, use strong and unique passwords with two-factor login, keep backups as in website backups, and keep the origin server hardened. A WAF does not fix a vulnerable plugin; it only makes exploitation harder while you patch. See also ecommerce hosting checklist, where a WAF is part of the baseline.
A worked example: what a WAF does with three requests
Picture three requests arriving at an online shop. The first is a normal visitor asking for a product page. The firewall passes it through. The second is a request to the login page that includes a string such as a database command in the username field, a typical injection attempt. The firewall matches it to a rule and blocks it before the application ever sees it. The third is a script that tries two thousand passwords on the admin login in a minute. A rate-limiting rule notices the volume and starts to challenge or block that address.
None of this requires you to change the shop’s code. That is the main appeal. It is also why a firewall cannot fix a vulnerable plugin: if an attacker finds a request that the rules do not recognise, it passes through to the flaw.
How should you maintain a WAF over time?
- Review the blocked requests each week at first, then monthly, to see false positives and real attacks.
- Keep rules updated; managed rule sets from your provider update automatically, but custom rules need care.
- Add exceptions narrowly: allow a specific path or parameter, not a whole class of requests.
- Test your login, checkout and API after any rule change.
- Combine it with updates and backups; see website backups.
What types of rules does a WAF use?
Start with managed rules and rate limiting. Add custom rules only for problems you can see in your logs, and document each one so you know why it exists.
| Rule type | What it does | Example |
|---|---|---|
| Managed rule sets | Maintained signatures for known attacks and common software | Blocks known WordPress plugin exploits |
| Custom rules | Rules you write for your site | Block a path or country, or allow only your office to reach /admin |
| Rate limiting | Limits requests per address or per path | Max five login attempts a minute |
| Bot management | Scores and challenges automated clients | Challenge a client that behaves like a scraper |
| Positive security model | Allows only requests that match a known good pattern | Accept only expected parameters on an API |
What is the difference between detection and blocking mode?
Most WAFs can run in a monitoring mode that logs what would be blocked without blocking it, and in a blocking mode that enforces the rules. The safe way to roll one out is to run in monitoring mode for a week or two, review what it flagged, add exceptions for legitimate traffic such as your checkout, payment callbacks and API clients, and then switch to blocking. Skipping this step is the usual cause of a firewall blocking real customers.
After you switch, keep watching: a plugin update or a new form can introduce requests that look suspicious to a rule. Keep a quick way to turn a rule off, and check the logs after every release. For online shops, see our ecommerce hosting checklist.
How do you choose a WAF?
- Check whether it comes with your CDN or host before you buy a separate product.
- Ask whether managed rules update automatically and who maintains them.
- Look for a monitoring mode and good logs, so you can tune before you block.
- Check limits on rules, requests and log retention on your plan.
- Test the login, checkout and API after turning it on.