Cloudflare adds a free CDN, DNS and security layer in front of your site. Set up correctly, your site gets faster and gains extra protection against attacks; set up with the wrong SSL setting, you'll run into the "Too many redirects" error or insecure connection problems. In this guide we set up Cloudflare correctly from start to finish.
What does Cloudflare do?
- DNS management: Fast and reliable DNS infrastructure.
- CDN and caching: Static files such as images, CSS and JS are served from the Cloudflare server closest to the visitor.
- Security: Hides your server's real IP address and filters malicious bots and application-layer attacks.
- Free SSL: The connection between the visitor and Cloudflare is encrypted automatically.
Step 1: Add your site to Cloudflare
- Create a free account at cloudflare.com and click Add a domain.
- Enter your domain and select the Free plan.
- Cloudflare automatically scans your existing DNS records. Always compare the list with your current DNS panel; if any records are missing (especially MX and TXT), add them manually.
Step 2: Set up DNS records and proxy status
Each record has a cloud icon next to it. The orange cloud (Proxied) means traffic passes through Cloudflare, while the grey cloud (DNS only) means it goes directly to the server.
| Record | Recommended status |
|---|---|
@ and www (website) | Orange (Proxied) |
mail, webmail, MX target | Grey (DNS only) |
ftp, names used for cPanel/SSH | Grey (DNS only) |
Cloudflare's free proxy only carries HTTP/HTTPS traffic. If you set the records pointing to your mail server to orange, you won't be able to send or receive email.
Step 3: Change the nameservers
Cloudflare gives you two nameservers in the form xxx.ns.cloudflare.com. In the panel of the company you bought the domain from, delete the existing nameservers and enter these two. The change usually takes effect within a few hours; Cloudflare emails you when your domain is activated.
Step 4: Choose the right SSL/TLS mode (the most important step)
There are four modes under SSL/TLS » Overview:
| Mode | What does it do? | Recommendation |
|---|---|---|
| Off | No encryption | Don't use |
| Flexible | Visitor → Cloudflare encrypted, Cloudflare → server unencrypted | Avoid |
| Full | Both sides encrypted, server certificate not validated | Temporary workaround |
| Full (strict) | Both sides encrypted and server certificate validated | Recommended |
If your server has a valid SSL certificate (cPanel's AutoSSL or Let's Encrypt), set the mode to Full (strict).
In Flexible mode, Cloudflare connects to your server over HTTP. If your server also redirects HTTP to HTTPS (e.g. via .htaccess), the request enters an infinite loop. Solution: set the mode to Full (strict).
Then turn on the following settings under SSL/TLS » Edge Certificates:
- Always Use HTTPS: On
- Automatic HTTPS Rewrites: On
- Minimum TLS Version: TLS 1.2
Step 5: Cache settings
- Caching » Configuration » Browser Cache TTL: The "Respect Existing Headers" option uses the cache headers sent by your server.
- If old files still show up after updating your site, clear the cache with Purge Cache » Purge Everything.
- Make sure the WordPress dashboard (
/wp-admin) and cart/checkout pages are not cached.
Step 6: Security settings
- Security » Settings » Security Level: Medium is sufficient.
- Bot Fight Mode: Reduces spam bots, but may affect some API and payment integrations; test after enabling it.
- If you're under attack, you can temporarily enable Under Attack Mode. This mode shows visitors a check screen for a few seconds; turn it off when the attack is over.
Verified search engine bots such as Googlebot and Bingbot are recognised by Cloudflare as "verified bots". When writing custom security rules, make sure you don't block these bots; otherwise you'll see crawl errors in Search Console.
Seeing the real visitor IP address
Behind Cloudflare, your server logs show Cloudflare's IP addresses. The real visitor IP arrives in the CF-Connecting-IP header. If you use Nginx, you can write real IPs to the logs with ngx_http_realip_module; on cPanel/LiteSpeed servers, the Cloudflare integration that usually comes built in does this.
Conclusion
When you set up Cloudflare with the Full (strict) SSL mode and the right proxy settings, your site becomes faster and gains an extra layer of security. If you also want protection at the infrastructure level alongside Cloudflare, take a look at our VDS servers with layered Corero + Stormwall DDoS protection. If you're curious how DDoS attacks work, see our DDoS guide.
Frequently Asked Questions
Is Cloudflare free?
Yes. Cloudflare's free plan includes DNS, CDN, basic DDoS protection and free SSL. It is sufficient for most corporate sites and blogs.
What causes the "Too many redirects" error?
It's usually caused by the Cloudflare SSL mode being set to "Flexible" while the server also redirects HTTP to HTTPS. If the server has a valid SSL certificate, setting the mode to "Full (strict)" solves the problem.
Does Cloudflare affect my email?
The proxy (orange cloud) must be off for MX records and the mail subdomain. Otherwise, email traffic won't work.
