HiBlog Networking and Protocols
How to Set Up Cloudflare for Your Website: DNS, SSL and Cache
- A. MounesiAuthor
- Release Date
- 6 minutesReading time
- 11Views
- A. Mounesi
- Published:
- 6 min read
- 11 views
You’ve decided to put your site behind Cloudflare; you’ve heard it speeds things up, stops attacks and comes with free SSL. But halfway through, one missing record is enough for the site to open fine while emails quietly stop arriving a few hours later! The good news is that if you follow the right order, connecting your site to Cloudflare is a hassle-free half-hour job.
In this guide you’ll set up Cloudflare step by step: noting down your current records, adding the domain, the difference between the orange and grey cloud, changing nameservers, setting SSL to Full (strict) and testing the cache, plus an important point for sites hosted in Iran.
Short answer: your site’s files and database stay on the same host; only the domain’s DNS moves to Cloudflare. First note down all current records, especially the email MX and TXT records. Then, in Cloudflare, choose Onboard a domain under Domains, compare the records with your list, put Cloudflare’s two nameservers in your domain registrar’s panel and, once the domain is active, set SSL to Full (strict).
Before you start: is Cloudflare right for your site?
Cloudflare has no servers in Iran. If your host and most of your visitors are in Iran and you turn on Cloudflare’s proxy, a local visitor’s request first goes to Cloudflare’s servers abroad and then comes back to your host in Iran; it gets slower, and when international connectivity is disrupted, the site won’t open even for users inside Iran. For a site like that, use Cloudflare only as DNS, with the grey cloud, or, if you also have a foreign audience, look at GeoDNS. For a site hosted abroad with an audience outside Iran, Cloudflare is a good choice.
1. Note down your current records
Cloudflare replaces your current DNS, so any record that isn’t there stops working once you change the nameservers. In cPanel, open Zone Editor in the Domains section and click Manage next to the domain. Write down the name, type and value of every row, especially these:
- The A record of the main domain and the www record
- MX records with the same Priority number
- TXT records for SPF, DKIM and DMARC
- Subdomains such as mail, shop or ftp
Also note the current nameservers from your registrar’s panel, so you have a way back if needed. If DNSSEC is on for the domain, turn it off before changing the nameservers.
2. Add the domain to Cloudflare
- Log in to the Cloudflare dashboard, click Onboard a domain under Domains and enter only the main domain, for example example.com, without www or https.
- Let Cloudflare scan your current records and choose a plan; the Free plan is enough for most sites.
- Under DNS → Records, compare the scanned list row by row with your notes and add any missing row with Add record; the automatic scan doesn’t find everything.

The image is from the Cloudflare documentation (CC BY 4.0).
Orange cloud or grey cloud?
Next to each web record, the Proxy status column has two states. Proxied, the orange cloud, means visitors connect to Cloudflare and Cloudflare connects to your host; Cloudflare’s cache, SSL and protection only work in this state. DNS only, the grey cloud, means Cloudflare just gives out the IP and visitors go straight to your host.
Always keep email records DNS only: Cloudflare’s proxy only passes web traffic, so if a name like mail or smtp turns orange, email stops working. MX and TXT records don’t even have a proxy option.
3. Change the nameservers
Cloudflare shows two nameservers assigned to your domain. Log in to the panel where you bought the domain, open the nameserver section, replace the two old names with these two and save. Activation usually takes a few hours and can take up to 24 hours; don’t touch the host or the old records in the meantime.
If you registered the domain with HiData, you change the nameservers in your client area. If the domain or www doesn’t open after the change, see How to Fix DNS_PROBE_FINISHED_NXDOMAIN.
4. Set SSL to Full (strict)

With the proxy on, there are two connections: browser to Cloudflare and Cloudflare to host. In Full (strict) mode both are encrypted and Cloudflare also checks the host’s certificate, which makes it the most secure mode. It requires a valid certificate on the host; cPanel’s AutoSSL or a Cloudflare Origin CA certificate is enough. If you don’t have one yet, see How to Install an SSL Certificate in cPanel.
- In the domain’s dashboard, go to SSL/TLS → Overview.
- If the automatic mode is on, choose the custom option, pick Full (strict) and save.
- Under SSL/TLS → Edge Certificates, turn on Always Use HTTPS so http addresses go to https.
Don’t choose Flexible: in that mode Cloudflare connects to your host over http, and if the host also redirects to https, the page gets stuck in a redirect loop (ERR_TOO_MANY_REDIRECTS). If you see error 526 after turning on the proxy, the host’s certificate is invalid or expired; fix it in cPanel.
5. Test the cache

By default Cloudflare caches static files such as images, CSS and JS, not the HTML pages themselves. To see it, open one of your site’s images in a new tab, press F12 and reload the page with the Network tab open. Under Headers, look for cf-cache-status: HIT means the file came from Cloudflare’s cache and MISS means it was fetched from the host this time.
If you changed a file and still see the old version, go to Caching → Configuration, click Purge Cache and use Custom Purge to clear just that file’s URL. In a shop, if you later decide to cache HTML too, always leave out the login, account, cart and checkout pages.
Finally, test everything
- Open the domain and www over https from two different connections.
- Log in to WordPress and send a test form.
- Send a message from an outside email account to an address on the domain and reply to it.
- If a request gives a 403 error after connecting, see How to Fix the 403 Forbidden Error.
FAQ
Emails stopped arriving after Cloudflare. Why?
Almost always an MX or TXT record was left behind, or the mail name turned orange. Compare your original list with DNS → Records and set the email records to DNS only.
Does Cloudflare replace my hosting?
No. The site still runs on your host; Cloudflare only answers DNS and, in proxy mode, sits in front of the site.
Hosting and domains at HiData
If your site is on HiData’s professional cPanel hosting, you’ll find your current records in that cPanel’s Zone Editor, and the free AutoSSL certificate is ready for Full (strict) mode. Wherever you get stuck connecting to Cloudflare, our 24/7 ticket support has your back!


