FreeAudit / Guides / How to set up Cloudflare on a website
How to set up Cloudflare on a website
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
- Add the domain in Cloudflare and pick the Free plan.
- Check the DNS records. The scan can miss some.
- Change the nameservers at your registrar.
- Add an A record for
@and forwww, pointing to your server. - Choose proxied or DNS-only for each web record.
- If proxied: set SSL/TLS to Full (strict).
- Redirect
wwwto the bare domain, or the other way round. - 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:
- the apex record (
example.com), - the
wwwrecord, - your email records (MX, SPF, DKIM, DMARC).
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.
| Item | What it is | Where you do it |
|---|---|---|
| Nameservers | Which company answers DNS questions for your domain | At your registrar |
| DNS records | The 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:
| Type | Name | Content | Proxy |
|---|---|---|---|
| A | @ | your server's IPv4 address | your choice |
| A | www | the same address | your choice |
| AAAA | @ | your server's IPv6 address, if it has one | your 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.
| Item | Proxied (orange cloud) | DNS-only (gray cloud) |
|---|---|---|
| Visitors connect to | Cloudflare | Your server directly |
| Your server's IP | Hidden | Public |
| Caching and DDoS protection | Yes | No |
| Cloudflare rules and analytics | Yes | No |
| Best for | Most public websites | Mail 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.
| Mode | Visitor to Cloudflare | Cloudflare to your server |
|---|---|---|
| Flexible | Encrypted | Not encrypted (HTTP) |
| Full | Encrypted | Encrypted, certificate not checked |
| Full (strict) | Encrypted | Encrypted, 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
- Starting with Flexible. Redirect loop if your server forces HTTPS.
- Proxying mail records. MX and TXT cannot be proxied. Keep the A record of a mail server DNS-only.
- Forgetting records at the switch. Copy every record before you change nameservers.
- Old advice. Some guides still tell you to turn on Auto Minify or Railgun. Cloudflare deprecated both. The Auto Minify API was deprecated on 5 August 2024. Railgun connections stopped working on 1 February 2024.
- Thinking DNS-only is protected. With a gray cloud, anyone can look up your server's IP address.
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:
| Topic | Contabo's guide | This guide |
|---|---|---|
| Proxied or DNS-only for your own server | Shows the orange cloud as a benefit, no trade-off | Explains both and the cost |
| First SSL mode | Calls Flexible "a good starting point" | Full (strict), and why Flexible loops |
| Auto Minify and Railgun | Recommends both | Both are deprecated |
| www and bare domain redirect | Not mentioned | Covered with an example |
| The A record for your server | Lists record types only | Shows 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
- Cloudflare: Onboard a domain
- Cloudflare: Proxy status
- Cloudflare: Full (strict) mode
- Cloudflare: Flexible mode
- Cloudflare: ERR_TOO_MANY_REDIRECTS
- Cloudflare: Manage subdomains
- Cloudflare: Default cache behavior
- Cloudflare: API deprecations (Auto Minify)
- Cloudflare blog: Railgun deprecation
- Caddy: Automatic HTTPS
- Contabo: How to set up Cloudflare for your website