2.6 Connecting your domain to Cloudflare
Cloudflare is one of the leading website optimization and security platforms in the world. It is a service that acts as a middle layer between your website and your visitors, providing improved performance, security and reliability. The platform offers a wide range of solutions, from speeding up page loads using a global content delivery network (CDN) to powerful protection against cyber attacks.
One of Cloudflare’s key features is DDoS protection, which automatically blocks malicious traffic, allowing your site to remain accessible even in high threat environments. Cloudflare also provides encryption capabilities using HTTPS, access control via firewalls (WAF), and intelligent traffic management. These features make Cloudflare an indispensable tool for website owners seeking stable and secure operation of their resources.
Important: before starting the setup, You need to ensure the following:
- You have access to the domain control panel at Your registrar.
- The domain is active and has no restrictions on changing NS servers.
- You have Your server’s IP address.
Step-by-step Connection Guide
1. Registration and obtaining Cloudflare NS servers.
Go to Cloudflare and create an account. After logging into Your account, click + Add ➔ Existing domain and enter Your domain. Select Quick scan for DNS records
and wait for the existing DNS records to be scanned.
If no records are found, then create at least two basic A
type records, for the main domain @
and for the alias www
, direct these records to Your hosting IP address.
Additionally: check automatically imported DNS records Add missing records if necessary Configure proxy status for each record (orange cloud - enabled, gray - disabled)
Choose a pricing plan (You can start with the Free plan).
2. Changing NS servers at the registrar.
Cloudflare will provide You with two NS servers, which need to be set up at Your current registrar.
If the domain is registered with TheHost:
If You purchased a domain from us and want to point it to CloudFlare, log into Your personal account, go to the Domain Names section, select the desired domain with Your mouse and click the Name Servers button. Be sure to activate the option Change domain NS servers.
If the domain is serviced by another registrar:
- Log into Your registrar’s domain control panel.
- Find the NS servers settings section.
- Replace the current NS servers with those received from Cloudflare.
- Save the changes.
Remember: if You have any other NS servers configured in the panel, You need to delete them and add exactly the records provided to You by CloudFlare. If You set up some of the first and some of the second – the domain will start working unstably.
3. Setting up DNS for mail in the Cloudflare panel.
Go to the DNS ➔ Records section, click + Add record.
Then add A
, TXT
, and MX records
for proper mail functionality.
If DKIM
or DMARC
or any other records are used and auto-search didn’t find them, in this case, these records also need to be added manually. An example of mail record settings is demonstrated in our instructions.
To save the entered record, click Save.
Important: be especially careful when configuring DNS records, as errors can lead to site inaccessibility. It is recommended to take a screenshot or save a copy of the current settings before making changes.
4. Setting up SSL certificate.
As soon as You add the domain to Your account, the network will protect the connection from the browser to Cloudflare with its own SSL. However, on the path from Cloudflare to Your site, You need to set up a secure connection – this can be done by installing an SSL certificate on the hosting, even a regular self-signed certificate will do, which is connected in the properties of Your required WWW domain in the SSL
tab.
If You don’t have SSL on Your Hosting, select the Flexible
option. Then users will see HTTPS connection in the browser, but Cloudflare itself will still transmit data in an unprotected form. Therefore, we do not recommend staying in this mode for long, to protect Your own data from interception, it is desirable to install SSL on the site as soon as possible.
If You already have a commercial certificate installed on Your Hosting, select Full (Strict)
in the checkbox.
Please note: if SSL is not installed on the Hosting, do not select the Full
and Full (Strict)
options, otherwise site visitors will see errors 525 and 526.
How to Clear Cache
When using Cloudflare, caching will occur by default, so after each update on the site, You will have to manually clear the cache. If You don’t do this, users will see the changed content for a certain time.
To clear the cache, go to the Caching ➔ Configuration tab. The Custom Purge button will clear the cache of any individual URL, while the Purge Everything button will remove all cache on Cloudflare servers, however, complete clearing will temporarily increase the number of requests to the server and the site may slow down. We recommend choosing the first option.
To avoid inconvenience for users due to outdated content, we recommend regularly clearing the cache when making changes to the site. If you frequently update information, consider setting up automatic cache clearing or reducing the lifetime of cached data in your Cloudflare settings. This will help maintain a balance between site loading speed and relevance of content for visitors.