FreeAudit

FreeAudit / Guides / How to set up Cloudflare on a website

How to set up Cloudflare on a website

Updated 2026-11-19 · by HTJ Studio

To set up Cloudflare, add your domain in the dashboard, check the DNS records it finds, then change your domain's nameservers at your registrar to the two Cloudflare gives you. Next, add an A record that points to your server's IP address and choose proxied (orange cloud) or DNS-only (gray cloud). We did exactly this for freeaudit.dev.

The short version

  1. Add the domain in Cloudflare and pick the Free plan.
  2. Check the DNS records. The scan can miss some.
  3. Change the nameservers at your registrar.
  4. Add an A record for @ and for www, pointing to your server.
  5. Choose proxied or DNS-only for each web record.
  6. If proxied: set SSL/TLS to Full (strict).
  7. Redirect www to the bare domain, or the other way round.
  8. Run an audit to check the result.

1. Add your site

In the Cloudflare dashboard, choose Onboard a domain and enter your apex domain, for example example.com. Cloudflare needs it to sit one level below a public suffix. example.com works. A subdomain such as blog.example.com is not accepted as the domain to add.

2. Check the DNS records

Cloudflare scans for your old records, but its own docs say the scan is not guaranteed to find all of them. Compare the list with your old DNS provider. Look at three things:

If you activate the domain without the right records, visitors can get a DNS_PROBE_FINISHED_NXDOMAIN error.

3. Nameservers or just DNS records?

These are two separate things. Do not mix them up.

ItemWhat it isWhere you do it
NameserversWhich company answers DNS questions for your domainAt your registrar
DNS recordsThe answers themselves (A, CNAME, MX, TXT)In Cloudflare, after the switch

Changing nameservers moves all DNS to Cloudflare. After that, you edit records only in Cloudflare. While Cloudflare checks that the nameservers changed, the domain shows as pending. Cloudflare says this can take up to 24 hours.

You can check the change yourself:

dig +short NS example.com

When it prints two names ending in ns.cloudflare.com, the switch has happened.

4. Point the domain at your own server

A VPS at Contabo, Hetzner or anywhere else gives you an IP address. Add these records in Cloudflare:

TypeNameContentProxy
A@your server's IPv4 addressyour choice
Awwwthe same addressyour choice
AAAA@your server's IPv6 address, if it has oneyour choice

Only A, AAAA and CNAME records can be proxied. MX and TXT records are always DNS-only.

5. Proxied or DNS-only?

This is the choice most guides skip.

ItemProxied (orange cloud)DNS-only (gray cloud)
Visitors connect toCloudflareYour server directly
Your server's IPHiddenPublic
Caching and DDoS protectionYesNo
Cloudflare rules and analyticsYesNo
Best forMost public websitesMail servers, verification records, setups where your own server does the work

Cloudflare recommends proxying records that serve web traffic. Proxying is on by default when you add a domain in the dashboard.

What we chose for freeaudit.dev: DNS-only. Caddy, our web server, gets its own certificate and handles the redirect. The cost is real: our server's address is public, and we get no Cloudflare cache or attack filter. We use Cloudflare for DNS only. If you want the cache and the protection, proxy the records.

6. SSL/TLS: use Full (strict)

This only applies to proxied records. It sets how Cloudflare talks to your server.

ModeVisitor to CloudflareCloudflare to your server
FlexibleEncryptedNot encrypted (HTTP)
FullEncryptedEncrypted, certificate not checked
Full (strict)EncryptedEncrypted, certificate checked

Choose Full (strict) whenever you can. Your server needs a certificate that is not expired, matches the hostname, and comes from a public certificate authority such as Let's Encrypt, or from Cloudflare's Origin CA. Port 443 must be open. If not, visitors see a 526 error.

Many guides tell you to start with Flexible. Do not. If your server already redirects HTTP to HTTPS, Flexible creates a redirect loop and visitors see ERR_TOO_MANY_REDIRECTS. Cloudflare's own troubleshooting page names this as a common cause.

7. Redirect www to the bare domain

Pick one address as the real one and send the other to it. Two addresses with the same page confuse search engines.

On the server, with Caddy, it takes a few lines:

www.example.com {
    redir https://example.com{uri} permanent
}

example.com {
    reverse_proxy localhost:3000
}

This is an example. Change the domain and the port. The word permanent sends a 301. We tested ours with curl -I https://www.freeaudit.dev. It returns 301 with location: https://freeaudit.dev/.

If you proxy through Cloudflare and have no server for www, Cloudflare's docs show another way: a proxied www A record that points anywhere, plus a Single Redirect rule.

8. Caching

For proxied sites, Cloudflare follows the cache headers your server sends. It does not cache a response that has Cache-Control: private, no-store, no-cache or max-age=0, a Set-Cookie header, or any method other than GET. It does cache a response with Cache-Control: public and a max-age above 0. So control caching with the headers your server sends. Start there before you change Cloudflare settings.

Mistakes to avoid

What the top guide covers and misses

Contabo's guide was the first result for this search when we ran it on 19 November 2026. It explains the basic steps well. These parts are missing or out of date:

TopicContabo's guideThis guide
Proxied or DNS-only for your own serverShows the orange cloud as a benefit, no trade-offExplains both and the cost
First SSL modeCalls Flexible "a good starting point"Full (strict), and why Flexible loops
Auto Minify and RailgunRecommends bothBoth are deprecated
www and bare domain redirectNot mentionedCovered with an example
The A record for your serverLists record types onlyShows the records to add

Their guide says it was last updated on 11 November 2026.

Check the result

Run FreeAudit on your domain. It tests the redirect from http to https, HSTS, the security headers and your email records, and says what to fix. FreeAudit is made by HTJ Studio.

FAQ

Do I have to change my nameservers?

For a normal setup, yes. Cloudflare must answer DNS for your domain. If you cannot change nameservers, Cloudflare says you can still use it through a certified hosting partner.

Is Cloudflare free?

There is a Free plan. You pick a plan when you add the site. Check Cloudflare's plan page for what each plan has.

Should I proxy or use DNS-only?

Proxy for most public sites, so you get the cache and the protection. Use DNS-only for mail and verification records, and when your own server must see visitors directly.

How long does it take to go live?

The domain stays pending until Cloudflare confirms your nameservers. Cloudflare says this can take up to 24 hours.

Sources