Security · Guide
How to Set Up a Web Application Firewall for WordPress
Short answer
To set up a web application firewall for WordPress, pick a cloud firewall such as Cloudflare or Sucuri, or a plugin firewall such as Wordfence. Point your DNS at the cloud service or install the plugin, turn on the managed rules, and check the firewall event log for blocked requests. Test the login page and admin area after setup to confirm nothing legitimate is blocked.
Key takeaways
- A WAF inspects requests before they reach WordPress and blocks known attack patterns.
- Cloudflare gives every plan a free managed ruleset that covers common WordPress exploits.
- Sucuri firewall plans start at $9.99 a month for one site as of November 2026.
- A plugin firewall runs inside WordPress, while a cloud firewall filters traffic first.
- Check the firewall event log after setup to catch rules that block real visitors.
What is a web application firewall for WordPress?
A web application firewall, or WAF, inspects every request sent to your site and blocks the ones that match known attack patterns.
It stops SQL injection, cross-site scripting, and login floods before they reach WordPress. Sucuri describes its WAF as protection from hacks, DDoS attacks, and zero-day exploits before they reach your server (Web Application Firewall).
Common attacks a WAF blocks include SQL injection, which tries to read or change your database through a form, and cross-site scripting, which tries to run scripts in a visitor browser.
Both use normal-looking requests, so a firewall must read the content of each request, not just its address.
A WAF is not a replacement for updates or backups. It filters traffic, but it cannot fix a plugin with a known flaw or restore files after an infection.
Cloud firewall or plugin firewall: which should you pick?
A cloud firewall filters traffic before it reaches your server, while a plugin firewall runs inside WordPress.
| Option | Where it runs | Cost as of November 2026 | Best for |
|---|---|---|---|
| Cloudflare | Cloud, before your server | Free managed ruleset on all plans | Most small sites |
| Sucuri WAF | Cloud, before your server | $9.99 a month Basic, $19.98 Pro | Sites that need cleanup help |
| Wordfence | Inside WordPress as a plugin | Free, Premium $149 a year | Sites that want one plugin |
Cloud firewalls also protect the server itself, because blocked requests never reach it. A plugin firewall still uses your server resources to inspect each request, so a flood can slow the site even when every attack is blocked.
Pick a cloud firewall if your host struggles under bot traffic. Pick a plugin firewall if you cannot change DNS or you want everything managed inside WordPress.
How do you set up the Cloudflare WAF?
Cloudflare protects WordPress with a free managed ruleset that is deployed automatically on every new zone.
- Create a free Cloudflare account and add your site.
- Change your domain nameservers to the two Cloudflare nameservers shown.
- Wait for DNS to update, then open \“Security → WAF → Managed rules\”.
- Check that the Cloudflare Free Managed Ruleset is deployed.
- Look for rules tagged wordpress and confirm the ones for your setup are on.
The free ruleset covers Log4J payloads, Shellshock, and very common WordPress exploits, according to Cloudflare support docs (Improving web security for content management systems like WordPress). The full Cloudflare Managed Ruleset and the OWASP Core Ruleset need a Pro plan or higher.
Cloudflare docs note that managed rules inspect request bodies up to 1 MB on the Free plan (Managed Rules). Most WordPress requests are far smaller, so this limit rarely matters.
If the firewall breaks the admin area, add a skip rule for /wp-admin/ limited to your own IP address. Cloudflare support docs show this pattern: a tightly defined skip rule that applies only to the admin portion of the site.
Before you change DNS, check our guide to Cloudflare SSL settings for WordPress, so the site keeps working over HTTPS after the move.
How do you set up the Sucuri WAF?
Sucuri WAF is a cloud firewall that filters traffic before it reaches your server, with a CDN included.
- Buy a Firewall or Platform plan on the Sucuri site.
- Add your domain in the Sucuri dashboard.
- Update your DNS so traffic passes through Sucuri.
- Wait for DNS to update, then confirm the site loads through the firewall.
Firewall-only plans cost $9.99 a month for Basic and $19.98 a month for Pro, per site, as of November 2026. Platform plans, which add scans and cleanup, cost $229, $339, and $549 a year (Web Application Firewall).
Platform Basic scans every 12 hours, Pro every 6 hours, and Business every 30 minutes. Every plan includes a 30-day guarantee.
Sucuri also lists a Junior Dev plan at $999.98 a year for 2 to 5 sites, and custom plans for 10 or more sites. One site per plan is the rule for the standard tiers, so count your sites before you buy.
Sucuri states that its firewall adapts to your CMS with custom rules. That matters for WordPress, because rules written for a generic site can block the editor or the login page.
How do you set up the Wordfence firewall?
Wordfence adds a firewall, a malware scanner, and login security in one free WordPress plugin.
- Install Wordfence Security from \“Plugins → Add New\” in your dashboard.
- Open \“Wordfence → Firewall\” and follow the setup to enable the firewall.
- Leave the default rules in place for the first week and watch the log.
- Check \“Wordfence → Live Traffic\” for blocked requests.
Wordfence runs on more than 5 million sites, according to Wordfence. Free users receive new firewall rules 30 days after Premium users, and Premium costs $149 a year per site as of November 2026.
Because the firewall runs inside WordPress, blocked requests still reach your server. That makes it a good fit for low-traffic sites, but a poor fit when floods alone can take the site down.
Our step-by-step guide to set up the Wordfence firewall covers the install and the first settings in detail.
Which rules should you turn on first?
Turn on the managed rules first, then add custom rules only for attacks you actually see.
Start with these:
- The managed ruleset, with the WordPress-tagged rules on.
- A rule that blocks requests to xmlrpc.php if you do not use Jetpack or remote publishing.
- A rule that challenges repeated login attempts.
- A rule that blocks requests for backup files such as .sql and .bak.
Cloudflare provides managed rulesets that protect against web application exploits, and each rule has a default action based on its severity (Managed Rules). Rules carry tags such as wordpress, so you can find and configure the WordPress rules as a group.
Start in a mode that logs but does not block, if your firewall offers it. A week of logs shows which rules would fire on real traffic, so you can fix false positives before any visitor is blocked.
Jetpack Security also includes a WAF, which stops bots before they reach wp-login.php and xmlrpc.php (How to Prevent Brute Force Attacks on WordPress). If you already run Jetpack, check whether its firewall covers the attacks you see before you add a second one.
A content security policy adds another layer on top of the WAF. Our guide to add a content security policy to WordPress explains how to set one up.
How do you test that the WAF is working?
Test the WAF by visiting the site as a stranger would, then checking the firewall event log.
- Open \“Security → Events\” in Cloudflare, or the firewall log in Sucuri or Wordfence.
- Load the homepage, log in, and save a post.
- Confirm each action worked and no rule blocked it.
- Try a harmless blocked pattern, such as a URL with script tags in it, and confirm the WAF stops it.
A WAF that blocks your own login is worse than no WAF. If the editor breaks, find the rule in the event log and add a narrow exception for your IP address only.
Repeat the test after every rules change. A new rule can break a form that worked yesterday, and the event log shows which rule fired within minutes of the change.
For wider attack data, see website security statistics.
What mistakes should you avoid with a WordPress WAF?
The biggest mistake is turning on a WAF and never reading its event log.
Avoid these errors:
- Stacking two firewalls that block each other.
- Blocking xmlrpc.php while Jetpack or a mobile app still needs it.
- Leaving the firewall in its default state for a shop with custom checkout fields.
- Forgetting to update DNS after a host move, so traffic bypasses the cloud firewall.
- Treating a WAF as a substitute for updates and backups.
A WAF filters traffic, but it cannot patch a vulnerable plugin. Keep WordPress, themes, and plugins updated, and keep a backup you have restored at least once.
Add security headers as a second layer. Our guide to add security headers to WordPress walks through the settings.
Frequently asked questions
Do I need a WAF if I already have a security plugin?
It depends on what the plugin does. Wordfence already includes a firewall, so adding a cloud WAF on top gives you two layers, which is fine. But two plugin firewalls, or a plugin firewall plus a second plugin that also filters logins, can block each other and slow the site.
Will a WAF slow down my WordPress site?
A cloud WAF can speed a site up, because it caches content through its CDN and blocks junk traffic before it reaches your server. A plugin WAF adds a small load, because every request is inspected inside WordPress. On a small site the difference is hard to notice.
Can a WAF block real visitors by mistake?
Yes, false positives happen, especially with forms, checkout pages, and the post editor. Check the firewall event log, find the rule that fired, and add a narrow exception for that page or your IP address. Never turn off the whole ruleset to fix one blocked page.
Is the Cloudflare WAF really free?
Yes, the Cloudflare Free Managed Ruleset is deployed automatically on every new zone, including free ones, and it covers common WordPress exploits. The full Cloudflare Managed Ruleset and the OWASP Core Ruleset need a Pro plan or higher, so free users get the smaller ruleset only.
Do I still need to update WordPress if I have a WAF?
Yes. A WAF blocks known attack patterns, but it cannot patch a vulnerable plugin or theme. Attackers find new flaws all the time, and an unpatched plugin stays open even behind a firewall. Update WordPress, themes, and plugins on a regular schedule.
Sources
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
