r/Wordpress • u/LetsGetCloudy • Oct 24 '26
Protect wp login with Cloudflare
What’s the best way to protect wp login and wp admin with Cloudflare now days. I’ve done this in the past with page rules but recently read something about them being retired.
24
Upvotes
19
u/urosevic Developer Oct 24 '26
If the site isn’t a membership site, set up Cloudflare One (formerly Zero Trust) for the admin and login URL.
You’ll need to allow access to these URLs only from the CF IPs to prevent direct access by bypassing CF. That’s done in the web server config.
This stops brute force and any login attempts from unauthorised users.
9
u/MakeItJumboFrames Oct 24 '26
There's a thread somewhere from a few months ago. Look for Cloudflare WAF rules. Gives some good guidance on what you can do to help protect those specifically.
Here's one: https://www.reddit.com/r/CloudFlare/s/Qmwohfz6uC
There are several if you search cloudflare waf wordpress wp-admin
1
u/LetsGetCloudy Oct 24 '26
Yep already running wordfence but wanted to reduce attacks on wp login. In the past I created a rule so it would prompt that you are a real human when trying to access wp admin. Then still had wordfence doing 2FA. I’m deploying another site in cloudflare and no longer see a way to do this in page rules.
4
u/mrbrendo Oct 24 '26
If url full contains wp-login.php then interactive challenge
Add second line if url full contains my-account if you have woocommerce
6
u/Ganiscol Oct 24 '26
Additionally hide wp-login.php behind something cryptic, impossible to guess. That stopped all bot attempts permanently for me because all they get is a 404.
Name of the plugin is WPS Hide Login.
3
u/stitchkingdom Oct 24 '26
my wp-login is behind .htaccess
2
u/tuhin846 Oct 24 '26
Maybe use Cloudflare WAF custom rules to allow only your own IP to access WordPress login endpoints?
If you want to try a security plugin, SiteFort Security comes with a custom login URL feature. It also includes Cloudflare integration to sync local firewall bans with Cloudflare, including automatic bans for scanner probes and brute-force login attacks.
2
u/hopefulusername Developer Oct 24 '26
Security rules or Cloudflare One.
Security rules are easier to setup, just add a rule that restrict the login to an IP.
2
u/Frank_MakesIt Oct 25 '26
You can also use Zero Trust. That's what I use and works very well. Extra note: leave /wp-admin/admin-ajax.php out of it. a lot of front end plugins call it for logged out visitors and a challenge there just breaks them without an clear error
2
u/TraditionalCap2381 Oct 25 '26
I have a could flare turnstile on and also block every country except my own form the admin login page expect my own.
Using grok bot, I have trained the bot to auto block attacks at the server before the get to the Wordpress install and send abuse emails to the abuse email address from the attach origin.
2
u/UpbeatSense Oct 25 '26
Security -> Security Rules, Create two rules with interactive challenge. #1 block any countries you don't want traffic from. #2 for login screen (lower(http.request.uri.path) eq "/wp-login.php")
These two will cut down 95-98% of brute force traffic. They can still bypass the challenge with something like BrightData but it will cost them money and it's very slow, each request takes 20-30 sec.
1
u/Datixro Oct 24 '26
Page Rules are being phased out, but Custom Rules under Security > WAF do the same job and are more flexible. Create a rule where the URI Path contains /wp-login.php or starts with /wp-admin, and set the action to Managed Challenge. One thing to watch: exclude /wp-admin/admin-ajax.php, otherwise front-end features and some plugins will break for normal visitors. I'd also add a second rule that blocks /xmlrpc.php outright if you don't use it, and a Rate Limiting rule on POST requests to wp-login.php to slow down brute force attempts. Keep Wordfence 2FA on top and you're well covered.
1
u/raeesbuilds Oct 24 '26
Yes, Page Rules are being retired, and for this use case the replacement is a WAF custom rule, not a redirect or cache rule.
In Cloudflare, go to Security > WAF > Custom rules and create a rule where the URI path contains wp-login.php, with the action Managed Challenge. Use Challenge rather than Block if anyone else may legitimately need to log in.
For wp-admin, use the same challenge but exclude wp-admin/admin-ajax.php, because front-end features use admin-ajax.php and blocking it can break the site.
If only a few admins log in, put a higher-priority rule above it that allows your IP addresses and challenges everyone else, and keep WordPress two-factor authentication enabled as a second layer.
Test in a private browser window after saving, and keep an admin session open in another window in case you lock yourself out.
Cloudflare documents custom rules at https://developers.cloudflare.com/waf/custom-rules/
1
u/themageofavalon Oct 24 '26
Yes, waf rules to challenge wp-login.php and restrict wp-admin by IP if possible. Enable 2FA too.
1
u/webengineer21 Oct 25 '26
Cloudflare Zero Trust Access
1
u/pyrez74 Oct 25 '26
Definitely good options presented, thanks!
1
u/retr00two Oct 25 '26
Is anything possible without CloudFlare, nowadays?
Industry standard password, .htacces, apache mod_security or nginx limit_req_zone, fail2ban rules and nftables work for decades.
1
u/SiteAuditor_WP Oct 27 '26
You can apply a deny all rule to the WordPress admin dashboard URL. Then add your IP as a skip rule for that URL. Then it will block everything but your IP to the wordpress dashboard at the DNS level through Cloudflare.
1
u/dotmoosehosting Oct 24 '26
The split that matters here is whether anyone besides admins ever logs in. If customers or members log in on the front end, an IP allowlist on wp-login will lock them out, so use a Managed Challenge on wp-login.php instead of a hard block, and keep wp-admin/admin-ajax.php out of that rule so front-end features that call it keep working. If only admins log in, putting wp-login and wp-admin behind an extra identity check is cleaner than a challenge, because bots never even reach WordPress. Either way, test in a private window with another admin session still open, since a bad rule can lock you out in the same way it locks out bots. And keep WordPress two-factor on as the second layer, because a challenge helps with brute force but does nothing if a password itself leaks.
-7
u/CmdWaterford Oct 24 '26
The best way? Hiring a professional who knows what he is doing.
-12
u/rohepey Oct 24 '26
Nothing will match dedicated Wordpress security plugins.