Cloudflare is a reverse proxy network that routes web requests through global edge nodes, accelerating delivery and filtering threats before traffic reaches the origin server. Each request passes through its distributed infrastructure, where caching, DDoS protection, and SSL/TLS termination happen at the edge rather than at the host. The result is a faster, more resilient site without requiring changes to the host's software or operating system.
What Cloudflare Does and How It Fits Into Your Stack
Cloudflare operates as a reverse proxy and edge network between your server and visitors, routing each request through its global content delivery network before it reaches your host. The proxy sits at the DNS layer: once you delegate your domain's nameservers to the service, all inbound traffic passes through its infrastructure. The platform then makes per-request decisions about caching, filtering, and forwarding based on rules you configure in the dashboard. For a detailed breakdown of how a content delivery network accelerates delivery, see how content delivery networks improve web performance.

The four core capabilities the platform adds to any stack are:
- CDN caching and static asset delivery. The platform stores cacheable responses at edge nodes worldwide, serving HTML, CSS, JavaScript, and image assets from the location nearest each visitor without touching the host.
- DDoS protection and WAF. Cloudflare absorbs volumetric DDoS protection attacks at the network layer and applies Web Application Firewall rules to filter malicious HTTP traffic before it reaches your host.
- SSL/TLS termination at the edge. The proxy handles the SSL/TLS handshake with the visitor, offloading cryptographic processing from your server and ensuring HTTPS is served regardless of host certificate configuration.
- DNS management and nameserver hosting. After delegation, the platform becomes the authoritative DNS provider for your domain, resolving records with low latency from the same edge network that serves your traffic.
Step 1: Create a Cloudflare Account and Add Your Domain
Cloudflare requires you to create a free account, enter your domain name, and allow the platform to scan your existing DNS records before you change anything. The scan imports your current A, CNAME, MX, and TXT records automatically so you can verify them before going live. Skipping this verification step is the most common cause of mail delivery failures and broken subdomains after nameserver delegation.

- Create a Cloudflare account using a work email address, following Cloudflare's account creation guide.
- Click Add a Site and enter your root domain (for example,
example.comwithout a subdomain prefix). - Select the free or a paid plan based on your traffic and security requirements.
- Review the auto-detected DNS records. Confirm that every A record, CNAME entry, and MX record matches what your current domain registrar shows. Add any missing records before proceeding.
- The dashboard displays two nameserver hostnames in the format
xxx.ns.cloudflare.com. Copy both values before moving to Step 2, as you will need them at your registrar.
Step 2: Update Nameservers at Your Domain Registrar
Cloudflare activates only after you replace your registrar's default nameservers with the two assigned nameserver hostnames shown in the dashboard. Until that change is saved and propagated, the service sits in a pending state and none of its proxy features apply to live traffic. DNS propagation can take up to 24 hours depending on the TTL value set on the previous nameserver records; for background on how DNS propagation works, see what is dns and how does it work.
- Log in to your domain registrar (Namecheap, GoDaddy, Google Domains, or whichever provider holds the registration).
- Navigate to the nameserver settings for your domain. Remove all existing nameserver entries listed.
- Enter both nameserver hostnames provided in Step 1 (format:
xxx.ns.cloudflare.com). The exact values are unique per account, so use the ones assigned to your zone, not generic examples. - Save the change at your registrar and allow up to 24 hours for DNS propagation. An email confirmation arrives when the zone activates. During propagation, some visitors may still reach your host directly, bypassing the edge network.
Step 3: Configure SSL/TLS and Security Settings
Cloudflare provides four SSL/TLS (Secure Sockets Layer/Transport Layer Security) encryption modes, and choosing the wrong one is the most common cause of redirect loops and broken HTTPS connections after activation. The mode controls how the proxy handles encryption between the visitor and the edge, and between the edge and your server. Getting the server-side half wrong creates either a security gap or an infinite redirect chain.

| SSL/TLS Mode | How It Works | When to Use |
|---|---|---|
| Off | No HTTPS encryption. All traffic between visitor and the edge travels over HTTP. | Testing only. Never for production. |
| Flexible | HTTPS from visitor to edge; unencrypted HTTP from edge to your server. | Only if the host has no SSL certificate installed. Avoid for production because traffic between the edge and your server is exposed. |
| Full | HTTPS to visitor and to your server. Host certificate can be self-signed. | Use if the host has any certificate installed but it is not CA-validated. |
| Full (Strict) | HTTPS to visitor and to your server. Host certificate must be CA-signed and valid. | Recommended for all production sites. Validates the host certificate and prevents man-in-the-middle exposure on the origin hop. |
Set the mode to Full (Strict) on any production site where the origin server already has a valid CA-signed certificate installed. After selecting the mode, navigate to SSL/TLS, then Edge Certificates to enable HSTS (HTTP Strict Transport Security). HSTS instructs browsers to refuse plain HTTP connections to the domain for a configurable duration, defined by IETF RFC 6797. The platform also supports TLS 1.3, standardized in IETF RFC 8446, providing improved handshake performance and forward secrecy compared to older protocol versions. NIST SP 800-44 recommends that public web servers enforce current TLS versions and disable legacy negotiation; the guidance applies directly to host configuration even when the edge handles termination, as documented in NIST SP 800-44 Version 2.
Step 4: Optimize Caching and Performance Settings
Cloudflare's caching layer cuts Time to First Byte (TTFB) by serving static assets from the edge node nearest the visitor instead of fetching from the host on every request. TTFB measures the latency between a browser sending an HTTP request and receiving the first byte of the response, a metric defined in the W3C Navigation Timing Level 2 specification. A cache hit eliminates the round-trip to the host entirely, which is why reducing Time to First Byte is a primary goal of CDN deployment. HTTP cache-control headers govern which responses the service stores and for how long, as defined in IETF RFC 7234. For high-traffic origins, combining CDN caching with server-side load balancing compounds the performance gain; how load balancing complements CDN caching for high-traffic origins is covered at load balancing vs auto scaling.
- Caching level: Standard. The platform caches responses based on file extension and the origin's cache-control headers. Standard mode respects your existing cache-control directives and caches common static file types (CSS, JavaScript, images, fonts) automatically.
- Browser cache TTL: 4 hours. This setting controls the cache-control max-age sent to the visitor's browser for cached assets. Four hours is a safe default that balances freshness with browser-side caching benefit.
- Auto Minify: enable for HTML, CSS, and JavaScript. The service strips comments, whitespace, and redundant characters from these file types before delivering them from the edge network, reducing payload size without touching origin files.
- Rocket Loader: enable with testing. Rocket Loader defers non-critical JavaScript to speed up page paint. Test all JavaScript-dependent features (payment widgets, dynamic forms, analytics) before enabling on production, as it can interfere with inline scripts that expect synchronous execution.
- Page Rule for dynamic URLs: Cache Level Bypass. Create a Page Rule targeting patterns such as
/admin/*and/cart/*with Cache Level set to Bypass. This prevents the proxy from caching authenticated sessions or personalized content, which would serve one user's data to another.
Troubleshooting Common Cloudflare Setup Problems
Cloudflare activation introduces three failure modes that account for the majority of post-setup support requests: redirect loops, mixed-content warnings, and origin connection errors. Each has a specific cause rooted in the interaction between the proxy's behavior and host configuration. Identifying which failure mode is occurring narrows the fix to a single setting change in most cases.
- ERR_TOO_MANY_REDIRECTS (redirect loop)
Cause: The SSL/TLS mode is set to Flexible while the host also enforces an HTTP-to-HTTPS redirect. The proxy forwards an HTTP request to the host; the host redirects back to HTTPS; the proxy forwards another HTTP request, creating an infinite loop.
Fix: Change the SSL/TLS mode to Full or Full (Strict). Remove any conflicting HTTP-to-HTTPS redirect rule on the host that operates on the connection from the published IP ranges. The redirect loop stops once the edge-to-host connection uses HTTPS directly.
- Mixed content warnings
Cause: Page HTML contains hardcoded HTTP asset URLs (images, scripts, stylesheets) that were not updated when the site moved to HTTPS. The browser blocks or flags these resources because they load over plain HTTP on an otherwise HTTPS page.
Fix: Enable Automatic HTTPS Rewrites in SSL/TLS, then Edge Certificates. This setting rewrites eligible HTTP asset URLs to HTTPS at the edge without requiring changes to origin content. For a permanent fix, update the origin CMS base URL setting to HTTPS so all newly generated links output the correct scheme.
- HTTP 521 Origin Connection Refused
Cause: The host firewall is blocking inbound connections from the proxy's IP ranges. The service attempts to forward the proxied request to the host and receives a TCP connection refusal.
Fix: Add the published Cloudflare IP ranges to the host firewall allowlist. The service maintains the current list of IP ranges in its own documentation. Do not hardcode specific addresses, as the published list is updated periodically. After allowlisting, also verify that the DNS record points directly to the host IP, not to a proxied hostname, which would create a proxy loop.
Tier-1 references: RFC 6797: HTTP Strict Transport Security · RFC 8446: TLS 1.3 · RFC 7234: HTTP Caching · W3C Navigation Timing Level 2 · NIST SP 800-44v2: Guidelines on Securing Public Web Servers
Further reading
Frequently Asked Questions
Does Cloudflare work with any web host or does it require specific hosting?
Cloudflare works with any host that allows nameserver changes at the domain registrar level, regardless of the hosting platform or control panel. You point your domain's nameservers to the service; the proxy then routes traffic to your existing host IP address. No software installation on the host is required for the free plan. Compatibility issues arise only with hosts that lock nameserver control at the registrar or that use shared IP addresses that conflict with the proxy orange-cloud mode.
Should I use Cloudflare's free plan or a paid plan for a production site?
The free plan covers nameserver delegation, basic CDN caching, SSL/TLS, DDoS protection, and Page Rules for most small to medium sites. Paid plans add advanced WAF rules, image optimization, more Page Rules, analytics, and priority support. Evaluate the free plan first against your traffic pattern and security requirements before committing to a paid tier. Do not base the upgrade decision on specific feature counts listed here; verify current plan limits in Cloudflare's official pricing page as the feature set changes.
How long does Cloudflare activation take after changing nameservers?
DNS propagation after a nameserver change can take up to 24 hours, though activation often completes within minutes once the registrar saves the change. You will receive an email from Cloudflare confirming activation. During propagation, some visitors may still reach your host directly rather than through the proxy.
What SSL/TLS mode should I choose in Cloudflare?
Use Full (Strict) for any production site where the origin server already has a valid SSL certificate installed. Full (Strict) encrypts both the visitor-to-edge and edge-to-host connections and validates the host certificate, preventing man-in-the-middle exposure at the origin hop. Avoid Flexible mode for production because it sends unencrypted HTTP traffic between the edge and your host even when the visitor sees HTTPS.









