Skip to content
New: Laravel Hosting, Node.js Hosting & GitHub DeploysSee the plans →
Products
Solutions
Developers

Guides

How to use Cloudflare with your Litehost site

Put Cloudflare's free plan in front of a Litehost site without downtime, the two settings that break sites, and why mail records stay DNS-only.

Introduction

Cloudflare sits between your visitors and your hosting. Visitors connect to Cloudflare’s servers and Cloudflare connects to ours. Along the way, it caches your static files, absorbs junk traffic, and terminates SSL at a data centre near the visitor. The free plan includes all of this and is suitable for most sites.

Cloudflare is optional. Your hosting already serves over HTTPS with a free certificate. You should consider Cloudflare if your audience is spread across continents, if your site is being scraped or flooded, or if you need its firewall rules.

Setting Up Cloudflare

Follow these steps in order so that your site keeps serving during the switch:

  1. Create a free account at cloudflare.com and add your domain. Cloudflare scans your existing DNS and imports the records it finds.

  2. Check the imported records against the DNS shown in your Litehost panel. The A records for the root domain and for www must point at the IP address the panel shows for your site. A record missed by the scan only causes a failure after the switch, when it is harder to spot.

  3. Set every record to DNS only (the grey cloud, not the orange one). You will turn the proxy on later.

  4. Cloudflare gives you two nameservers. Set these where the domain is registered:

    • Domain registered with Litehost: log in at app.getlitehost.com, open Domains, select the domain, and update the nameservers. Some extensions, including .com.ng, are still managed by our team and do not show a nameserver option. For those, open a ticket from client.getlitehost.com/support with the two nameservers, and we will usually set them within a few hours.
    • Domain registered elsewhere: replace the nameservers at that registrar.

    In either case, remove the old nameservers completely. A leftover nameserver gives two different answers to the same DNS question, and a visitor may receive either one.

  5. Wait for Cloudflare to confirm the domain is active, which usually takes minutes and sometimes hours. Your site keeps serving because the records have not changed, only who answers for them.

At this point, Cloudflare is only your DNS host and the site works as before.

Required Settings

Most Cloudflare problems come from one of the following two settings.

SSL/TLS Mode

The SSL/TLS mode must be Full (strict). In the Cloudflare dashboard under SSL/TLS, there are four modes.

The “Flexible” mode serves HTTPS to the visitor but connects to your hosting over plain HTTP. Your hosting redirects HTTP to HTTPS, so the two loop and the browser reports “too many redirects”. Your Litehost site already has a valid certificate, which is what strict mode verifies.

Enabling the Proxy

Turn the proxy on only after HTTPS works. Your hosting renews its certificate automatically by answering a challenge on your domain. This works through Cloudflare’s proxy once a certificate exists, but if you proxy a new domain before the first certificate is issued, the challenge may fail.

Confirm the padlock works with records on DNS only, then switch the root and www records to the orange cloud.

Mail Records

The proxy handles web traffic only, and Cloudflare does not forward mail protocols. The following records must always stay on the grey cloud:

  • The MX record’s target (usually mail.yourdomain.com)
  • The mail subdomain’s A record
  • Any autodiscover, autoconfig, imap, smtp, or webmail records

If these are proxied, mail applications cannot connect and webmail times out, while the website keeps working. Cloudflare usually warns about this on the DNS page.

The proxy does not affect SPF, DKIM, and DMARC TXT records. However, you should confirm that the import copied them, because mail may land in spam without SPF.

Verifying the Setup

As with any nameserver change, resolvers hold the old answer until their cache expires, so your phone and laptop may disagree for a few hours.

Once the switch has settled, open your site and check the response headers in your browser’s developer tools (Network tab, then the first request):

  • server: cloudflare means traffic is flowing through the proxy.
  • cf-cache-status: HIT on your images, CSS, and JavaScript means the cache is working. DYNAMIC on the page itself is expected, since HTML is not cached by default.

If the site loads but something specific fails, check the SSL mode and look for a record that is proxied when it should not be. If you need help, open a ticket from client.getlitehost.com/support and we will check the domain with you.

Keep reading

Other guides

Start building today

Laravel apps with queues and Horizon, WordPress stores, Node.js servers. One container with SSH, deploys from GitHub and people who answer. One bill a year.

Launch my site