Skip to content

Map Custom Domain Using Cloudflare DNS

After the CloudFront distribution is created, the next step is to map your custom domain to it using Cloudflare DNS. This ensures users access your site through your domain instead of the default CloudFront URL.


  1. Locate the CloudFront distribution domain name from the distribution details page, for example:

    d123abcd9xyz.cloudfront.net
    
  2. Sign in to the Cloudflare dashboard and open the domain you want to map.

  3. Navigate to DNS → Records.

  4. Add a new DNS record with the following settings:

    Field Value
    Type CNAME
    Name Domain label (e.g., @, www, docs)
    Target Your CloudFront distribution domain name
    Proxy status DNS only (unproxied) 🔴
    TTL Auto

    Example mappings:

    Domain Name Target
    example.com @ d123abcd9xyz.cloudfront.net
    www.example.com www d123abcd9xyz.cloudfront.net
    docs.example.com docs d123abcd9xyz.cloudfront.net

    Warning

    Do not enable Cloudflare proxy (orange cloud). The record must remain DNS only for CloudFront to correctly handle SSL and routing.

  5. (Optional) Enable Always Use HTTPS if you want Cloudflare to enforce HTTPS redirects.
    CloudFront already performs HTTP → HTTPS redirection, so this step is optional.

    • Go to SSL/TLS → Edge Certificates
    • Enable Always Use HTTPS
  6. (Optional) Disable Automatic HTTPS Rewrites if your application requires precise header behavior.

    • Go to SSL/TLS → Edge Certificates
    • Disable Automatic HTTPS Rewrites
  7. Allow several minutes for DNS propagation (typically 1–10 minutes, up to 1 hour globally).