Cloudflare CDN Integration

Introduction

Cloudflare provides authoritative DNS services as well as its own CDN and reverse proxy.

This guide uses Cloudflare only as the DNS provider for a dedicated static hostname such as cdn.example.com. A DNS-only CNAME points that hostname to the CDNsun service, so requests for static files go directly to CDNsun instead of passing through two CDNs.

Configure Cloudflare DNS for CDNsun

  1. Sign in to Cloudflare, select the zone that contains the hostname, and open DNS > Records. Select Add record. Cloudflare documents the same process in its DNS record guide.

  2. Create the CNAME record with these values:

    Type: CNAME
    Name: cdn
    Target: your CDN Service Domain
    Proxy status: DNS only
    TTL: 1 hour (3600 seconds)

    Enter only the target hostname supplied for the CDNsun service. Do not include https://, a path, or a trailing slash. For the zone example.com, the name cdn creates cdn.example.com.

  3. Confirm that Proxy status shows DNS only, and save the record. In this mode Cloudflare answers DNS queries but does not proxy, cache, protect, or analyze HTTP and HTTPS requests for this hostname. CDNsun handles content delivery instead. Cloudflare explains this behavior in its proxy status documentation.

    This setting applies only to the dedicated static hostname. It does not require changing the proxy status of the main website or its other DNS records.

    Why DNS only? If Proxy status is set to Proxied, each file request goes through Cloudflare first and CDNsun second. That puts two CDNs in the same path. This guide uses Cloudflare only for DNS, so keep DNS only and let CDNsun deliver the files directly. Advanced multi-CDN designs exist, but they require deliberate routing and are outside this guide. Cloudflare discusses them in its multi-vendor reference architecture.

  4. Update the website or application so public static asset URLs use the dedicated HTTPS hostname. Keep dynamic pages, forms, account routes, and API requests on their intended application hostname.

    https://cdn.example.com/images/example.jpg
    https://cdn.example.com/css/app.css
    https://cdn.example.com/js/app.js
  5. Verify that DNS resolves and that a known static file is available over HTTPS. Run the following commands with your hostname and a real static asset path:

    dig +short cdn.example.com
    curl -I https://cdn.example.com/path/to/static-file.css

    The DNS lookup must return an answer, the HTTPS request must complete without a certificate error, and the static file should return a 200 response. You can also check the DNS result with CDNsun Dig Online and inspect the HTTP response with CDNsun Curl Online.

Contact Us

  _  __   __   __    ____    
 | |/ //  \ \\/ //  |  _ \\  
 | ' //    \ ` //   | |_| || 
 | . \\     | ||    | .  //  
 |_|\_\\    |_||    |_|\_\\  
 `-` --`    `-`'    `-` --`