Cloudflare for a site on cPanel hosting

Cloudflare sits in front of the site: it speeds up loading, caches static files and filters bots. The domain DNS is then served by Cloudflare.

1. SSL on the hosting first

Wait until AutoSSL issues the certificate for the domain (how to check). If Cloudflare proxying is turned on earlier, the Let's Encrypt check may fail.

2. Move the DNS records

Add the site to Cloudflare. It imports the records itself, but compare them with the cPanel "Zone Editor": A records for the domain and www, MX, TXT (SPF, DKIM, DMARC).

Records to move to Cloudflare
Records to move to Cloudflare
RecordSetting
example.com, wwwproxied (orange cloud)
mail, ftp, cpanel, webmail, webdiskDNS only (grey cloud) - otherwise mail apps, FTP and cPanel login stop working
MX, TXTas in cPanel, unchanged

Then change the name servers at the registrar to the ones Cloudflare gives you.

3. SSL mode

In Cloudflare: "SSL/TLS" -> "Full (strict)". Do not use "Flexible": together with the HTTPS redirect on the hosting it causes an endless redirect.

What changes after connecting

  • DNS records are edited in Cloudflare; the cPanel Zone Editor no longer affects the domain;
  • IP blocking in cPanel stops working - the site sees Cloudflare addresses: block in Cloudflare instead (details);
  • after editing CSS or images, clear the Cloudflare cache: "Caching" -> "Purge Everything".

The SPF, DKIM and DMARC records suggested by cPanel must be added to Cloudflare by hand: SPF, DKIM and DMARC.

Questions and answers
Full (strict). Flexible together with the HTTPS redirect on the hosting causes an endless redirect.
The mail record and MX must not be proxied: set mail to DNS only (grey cloud).