XiaTools

How to Point a Subdomain to External Cloud Storage Buckets

Updated 09 Oct 2026

Pointing a custom domain or subdomain to an external cloud storage provider requires careful configuration of DNS records, bucket policies, and SSL certificates to ensure secure and reliable access. When you want to point cname to s3 bucket resources, direct CNAME mapping often fails because standard object storage endpoints use dynamic IP addresses and virtual-hosted-style URLs that do not support naked root CNAME records natively. This comprehensive guide walks you through the exact technical requirements, DNS configurations, and security protocols needed to successfully map your subdomain to cloud storage buckets.

Before making any DNS changes, verify your current domain routing and record propagation status using the CNAME Lookup tool, which helps you quickly inspect existing aliases and verify whether your target endpoints resolve correctly across global recursive resolvers.

Understanding Storage Endpoint Architecture

Cloud storage services like Amazon S3, Google Cloud Storage, and Azure Blob Storage are designed to serve files via HTTP and HTTPS using specific regional or global URL structures. Understanding how these endpoints function is critical when configuring your DNS provider.

Virtual-Hosted Style vs. Path Style URLs

Modern cloud storage primarily relies on virtual-hosted-style URLs, where the bucket name forms part of the hostname:

https://example-bucket.s3.us-east-1.amazonaws.com

When a user requests assets.example.com, your goal is to have the browser request content from the underlying storage endpoint while keeping your custom brand visible in the address bar. However, standard object storage cannot natively validate arbitrary SSL certificates for custom domains without an intermediary proxy, Content Delivery Network (CDN), or specific static website routing rules.

Why Direct CNAME Aliasing Fails

If you create a standard CNAME record directly pointing assets.example.com to example-bucket.s3.us-east-1.amazonaws.com, you will likely encounter HTTP 404 or certificate name mismatch errors. This happens because:

  1. The storage server receives a Host header matching your custom domain (assets.example.com), but its internal virtual host routing expects the S3 hostname.
  2. The default TLS certificate presented by the storage endpoint covers *.s3.amazonaws.com, not your custom domain.

To bypass these limitations, you must use a CDN layer like Amazon CloudFront, Cloudflare, or an Application Load Balancer in front of your storage bucket, or configure static website hosting with a matching bucket name.

Integration Method SSL Support Custom CNAME Support Complexity Best Use Case
Storage + CDN (Recommended) Full Custom SSL Yes (CNAME/Alias) Medium High-performance public assets, media delivery
Static Website Hosting Limited/HTTP Only Regional dependent Low Simple static HTML sites, low traffic
Reverse Proxy / ALB Full Custom SSL Yes High Enterprise security, strict compliance rules

Step-by-Step Configuration: Storage Bucket with CDN

This is the industry-standard method for pointing a custom subdomain to an S3 bucket securely with full HTTPS support.

Step 1: Create and Configure Your Storage Bucket

Log in to your cloud provider console and create a bucket. For this example, let's assume your bucket name matches your desired subdomain: assets.example.com.

  1. Navigate to your storage console and select Create bucket.
  2. Enter assets.example.com as the bucket name.
  3. Uncheck Block all public access if you intend to serve public assets, or keep it enabled if your CDN will use an Origin Access Control (OAC).
  4. Create the bucket.

Step 2: Set Up the CDN Distribution

To handle SSL termination and custom CNAME routing, create a distribution in your CDN service.

  1. Open your CDN console and choose Create Distribution.
  2. Select your S3 bucket (assets.example.com.s3.amazonaws.com) as the Origin domain.
  3. Configure Origin Access Control (OAC) to restrict direct public access to your S3 bucket, ensuring users must access files through the CDN.
  4. Under Viewer Protocol Policy, select Redirect HTTP to HTTPS.
  5. In the Alternate Domain Name (CNAME) section, add your custom subdomain: assets.example.com.
  6. Select an active SSL/TLS certificate from your certificate manager that covers assets.example.com.
  7. Save and deploy the distribution. Note the generated CDN domain name, such as d111111abcdef8.cloudfront.net.

Step 3: Configure Your DNS Records

Now, update your DNS zone file at your domain registrar or DNS hosting provider. Names of menu items may differ slightly depending on your provider, but you will generally look for DNS Management, Zone Editor, or DNS Records.

Add a CNAME record pointing your subdomain to your CDN distribution domain:

Type: CNAME
Name: assets
Value: d111111abcdef8.cloudfront.net
TTL: 3600

If you are configuring this on your root domain apex (e.g., example.com), your DNS provider must support CNAME flattening, ALIAS, or ANAME records. For subdomains like assets.example.com, a standard CNAME record is fully compliant with RFC standards.

Alternative: Static Website Hosting Method

If your storage provider supports static website hosting and you do not require a CDN layer, you can map a bucket whose name exactly matches your custom domain (assets.example.com).

  1. Enable Static website hosting in your bucket properties.
  2. Set your index document to index.html.
  3. Add a bucket policy allowing public read access:
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::assets.example.com/*"
    }
  ]
}
  1. In your DNS settings, add a CNAME record pointing to your regional website endpoint:
Type: CNAME
Name: assets
Value: s3-website-us-east-1.amazonaws.com

Verification and Troubleshooting

Once configured, verify that your DNS changes have propagated and your endpoint responds correctly.

Using Command Line Tools

Run dig or nslookup in your terminal to check record resolution:

dig assets.example.com CNAME

Expected output sample:

;; ANSWER SECTION:
assets.example.com.    300    IN    CNAME    d111111abcdef8.cloudfront.net.

Test HTTPS connectivity using curl:

curl -I https://assets.example.com/index.html

Expected response:

HTTP/2 200 
Content-Type: text/html
Server: AmazonS3

Common Mistakes and How to Fix Them

  • Error: DNS Zone Conflict (CNAME and MX/TXT record clash)
    • Cause: You cannot create a CNAME record for a name that already has active MX, TXT, or SOA records (especially common on root domains).
    • Fix: Use a subdomain (e.g., cdn.example.com or assets.example.com) for your CNAME, or use an ALIAS/ANAME record if your DNS provider supports apex flattening.
  • Error: SSL Certificate Mismatch (ERR_CERT_COMMON_NAME_INVALID)
    • Cause: The CDN or storage endpoint is presenting a default storage certificate rather than a custom certificate matching your subdomain.
    • Fix: Ensure you have imported or validated an SSL certificate in the correct region (e.g., US East / N. Virginia for CloudFront) and attached it to your CDN distribution.
  • Error: Access Denied (HTTP 403)
    • Cause: Bucket policies or public access block settings prevent the CDN or public users from reading the objects.
    • Fix: Verify your bucket policy JSON syntax and ensure OAC permissions are properly synchronized between the storage bucket and the CDN.

Setup Checklist

  • Create storage bucket with correct naming conventions.
  • Provision and validate an SSL certificate for your target subdomain.
  • Configure a CDN distribution or static website endpoint pointing to the bucket.
  • Add the correct CNAME record in your DNS management console.
  • Verify global DNS propagation and HTTP/HTTPS responses using command line tools or online lookups.

Frequently asked questions

Can I point my root domain (example.com) directly to an S3 bucket using a CNAME?

No, standard DNS specifications prohibit placing a CNAME record on a root or apex domain because it conflicts with mandatory MX and SOA records. Instead, you must use a subdomain like assets.example.com, or use an ALIAS, ANAME, or CNAME-flattening feature provided by your DNS host.

Why do I get a 403 Forbidden error after setting up my CNAME?

A 403 Forbidden error typically occurs when the S3 bucket's public access block settings are too restrictive or your CDN configuration lacks proper Origin Access Control (OAC) permissions to read files from the bucket. Verify your bucket policy allows read actions for your specific CDN service principal.

Do I need a CDN like CloudFront to point a custom domain to S3?

While you can use S3 static website hosting endpoints directly with DNS, it only supports HTTP out of the box and limits custom SSL certificate binding. Using a CDN layer is strongly recommended because it provides free custom SSL termination, edge caching, and secure HTTPS access.

How long does it take for my CNAME record to start working?

DNS propagation typically takes anywhere from a few minutes up to 24 hours, depending on the TTL (Time to Live) value you configured on your old records and how quickly global recursive DNS servers update their caches.

How do I check if my CNAME record was configured correctly?

You can use command-line utilities like dig or nslookup to query your subdomain's CNAME record. Additionally, running an online CNAME lookup tool allows you to verify that your DNS records resolve properly across multiple geographic regions.

Related articles

Free tools