Overview
Cloudflare is a robust security and performance tool that helps protect your WordPress website from attacks, reduces downtime, and improves speed. This guide will walk you through integrating Cloudflare with your WordPress site.
Step 1: Sign Up or Sign In to Cloudflare
- If you don’t have a Cloudflare account, you can sign up for one free on the company's website.
- If you already have an account, simply sign in.
- Click “Add a Site” and enter your domain name.
- Cloudflare will scan your existing DNS records.
Step 2: Update Your Nameservers
- Cloudflare will provide new nameservers.
- Log into your domain registrar (GoDaddy, Namecheap, etc.).
- Update your DNS nameservers to Cloudflare’s.
- Wait for the changes to propagate (it may take a few hours).
Step 3: Configure Security Settings
- Enable Web Application Firewall (WAF) (available on Pro+ plans).
- Turn on DDoS Protection (enabled by default).
- Set up Rate Limiting to block excessive login attempts.
Step 4: Secure Your WordPress Admin Login (wp-admin & wp-login.php)
Protecting your WordPress admin panel is crucial to prevent brute-force attacks and unauthorized access. Follow these steps to secure it using Cloudflare:
Block Unwanted Access to wp-login.php
Option 1: Restrict Access by IP Address
If you have a static IP address, allow only your IP to access the login page:
- Go to Cloudflare Dashboard → Security → WAF (Firewall Rules).
- Click Create a Firewall Rule.
- Name the rule “Restrict WP Login.”
- Set the following conditions:
- Field: URI Path contains /wp-login.php
- Field: IP Address is not [Your IP Address]
- Select “Block” as the action.
- Save and Deploy.
🔹 This will block all login attempts except from your IP.
Option 2: Challenge Suspicious Traffic with JS Challenge or CAPTCHA
If you don’t have a static IP or multiple users need access:
- Go to Cloudflare Dashboard → Security → WAF (Firewall Rules).
- Create a rule with:
- URI Path contains /wp-login.php
- Action: JS Challenge or Managed Challenge (CAPTCHA).
- Save and Deploy.
🔹 This adds an extra verification step to prevent bots from reaching the login page.
Enable Rate Limiting to Prevent Brute-Force Attacks
- Go to Security → WAF → Rate Limiting Rules.
- Click Create a Rule.
- Set the following:
- If URI Path contains /wp-login.php
- Requests exceed 10 per minute
- Action: Block for 15 minutes.
- Save and Deploy.
🔹 This prevents repeated login attempts by hackers and bots.
Disable XML-RPC to Block Automated Attacks
The xmlrpc.php file is often targeted by bots to brute-force WordPress logins.
- Go to Firewall Rules → Create Rule.
- Set:
- URI Path contains xmlrpc.php
- Action: Block.
- Save and Deploy.
🔹 This stops unnecessary login attempts via XML-RPC, reducing server load.
Use Cloudflare Access for Extra Security (Recommended)
For ultimate protection, use Cloudflare Access to lock down your admin page.
- Go to Zero Trust Dashboard → Access.
- Create a rule:
- URL Path contains /wp-admin
- Require authentication via: Google, Microsoft, or OTP.
- Save and Deploy.
🔹 Only verified users will be allowed to access your admin panel.
Step 5: Optimize Performance
- Enable Automatic Platform Optimization (APO) for full-page caching.
- Turn on Rocket Loader for faster JavaScript loading.
- Enable Auto Minify to reduce file sizes.
Step 6: Install Cloudflare WordPress Plugin
- Install the Cloudflare plugin from the WordPress plugin directory.
- Connect it to your Cloudflare account.
- Apply recommended settings.
✅ Best Practices
✔ Use Full (Strict) SSL for maximum security.
✔ Block XML-RPC to prevent brute-force attacks.
✔ Create Page Rules to exclude admin pages from caching.
✔ Monitor Traffic Analytics in Cloudflare for threats.
✔ Block unauthorized IPs from accessing wp-login.php.
✔ Use CAPTCHA or JS Challenge to prevent bot attacks.
✔ Limit login attempts with Rate Limiting.
✔ Disable XML-RPC to block automated brute-force attempts.
✔ Use Cloudflare Access for maximum protection.