Cloud 9.01

Configure DNS

Understanding TTL, CNAME records, Fastly endpoints, and root domain limitations.

Exam Critical: Understanding DNS configuration, TTL values, CNAME records, and Fastly DNS endpoints is important for the exam!

Configure DNS

mindmap root((DNS Config)) Before Going Live Lower TTL value Faster propagation DNS changes CNAME Records Point to Fastly www subdomain DNS endpoint Root Domain Limit Cannot use CNAME No example com Redirect required Workflow Redirect root to www CNAME www to Fastly DNS propagation

DNS Configuration Overview

Going Live with Magento Cloud

DNS Configuration When You're Going Live

Proper DNS configuration is critical for launching your Magento Cloud site to production.

Key Steps:
  1. Lower TTL value before going live
  2. Use CNAME records to point to Fastly
  3. Handle root domain limitations properly
  4. Set up redirects from root to www

Step 1: Lower TTL Value

Time-To-Live (TTL) Configuration

Before Going Live

Lower the Time-To-Live (TTL) value. This will help the DNS propagate sooner.

What is TTL?

Definition:

Time-To-Live (TTL) is the duration that DNS records are cached by DNS servers and clients.

How It Works:
  • DNS servers cache your records for TTL duration
  • After TTL expires, they request fresh data
  • Lower TTL = faster updates propagate
  • Higher TTL = less DNS traffic, but slower updates

Recommended TTL Strategy

Timing TTL Value Purpose
Normal Operations 3600 seconds (1 hour)
or 86400 seconds (24 hours)
Standard caching for stability
24-48 Hours Before Launch 300 seconds (5 minutes) Prepare for quick DNS changes
During Launch 300 seconds (5 minutes) Quick propagation of changes
After Launch (24-48 hours) 3600 seconds (1 hour) Return to normal caching
Why Lower TTL Before Launch?
  • Faster propagation: Changes spread quickly
  • Easier rollback: Can revert if issues occur
  • Reduced downtime: DNS updates faster
  • Testing flexibility: Can make adjustments quickly

How to Lower TTL

Steps:
  1. Log in to your DNS provider (e.g., Cloudflare, Route53, GoDaddy)
  2. Find your domain's DNS records
  3. Locate TTL setting for A records and CNAME records
  4. Change TTL to 300 seconds (5 minutes)
  5. Save changes
  6. Wait for old TTL to expire (wait the OLD TTL duration)
  7. Now ready to make DNS changes with fast propagation

Step 2: Use CNAME Records

Point to Fastly DNS Endpoint

CNAME Configuration

Use CNAME records to point to the Fastly DNS endpoint.

What is a CNAME Record?

Definition:

CNAME (Canonical Name) record maps one domain name (alias) to another domain name (canonical).

Example:
www.example.com  CNAME  prod-fastly-endpoint.cloud.magento.com

When users visit www.example.com, DNS resolves to Fastly's endpoint.

Fastly DNS Endpoint

What is Fastly?
  • Magento Cloud uses Fastly CDN for content delivery
  • Fastly provides DNS endpoints for your environment
  • Acts as edge server and caching layer
  • Improves performance and security
Finding Your Fastly Endpoint:
  1. Log in to Project Web Interface
  2. Navigate to Production environment
  3. Click Routes or Domains
  4. Find Fastly DNS endpoint
  5. Format: {env}-{project}.magentosite.cloud

Root Domain Limitation

CNAME Cannot Be Used for Root Domain

Critical Limitation

It is important to note that you cannot use a CNAME record for the root domain name (for example, bonlineco.com).

Why This Limitation Exists

DNS RFC Specification:
  • DNS standards prohibit CNAME at root (apex domain)
  • Root domain must have SOA and NS records
  • CNAME would conflict with other required records
  • Technical limitation of DNS protocol
Examples:
  • Cannot CNAME: example.com (root/apex)
  • Can CNAME: www.example.com (subdomain)
  • Can CNAME: shop.example.com (subdomain)
  • Can CNAME: store.example.com (subdomain)

Solution: Redirect Root to WWW

Handling Root Domain

Recommended Approach

As such, you would need to redirect bonlineco.com to www.bonlineco.com.

Two-Step Configuration

Step 1: Set up CNAME for www

You would set up a CNAME record for www.bonlineco.com to point to Fastly.

www.bonlineco.com  CNAME  prod-abc123.magentosite.cloud
Step 2: Redirect root to www

Configure root domain (bonlineco.com) to redirect to www.bonlineco.com

Methods for Root Domain Redirect

Method How It Works Pros/Cons
DNS Provider Redirect Many DNS providers offer HTTP redirect feature ✅ Easy
✅ Built-in feature
❌ Provider-dependent
A Record + Web Server Point root to server that redirects to www ✅ Universal
❌ Requires server
❌ Single point of failure
ALIAS/ANAME Record Some providers offer CNAME-like for root ✅ Works like CNAME
❌ Not all providers support
Cloudflare CNAME Flattening Cloudflare allows CNAME at root ✅ Simple
❌ Cloudflare only

Complete DNS Setup Example

Full Configuration Workflow

Scenario: Launching bonlineco.com

1. Prepare (24-48 hours before launch)
# Lower TTL in DNS provider
TTL: 300 seconds (5 minutes) for all records
2. Get Fastly Endpoint
# From Magento Cloud Web Interface
Fastly Endpoint: prod-abc123xyz.magentosite.cloud
3. Configure DNS Records
Record Type Name Value TTL
CNAME www prod-abc123xyz.magentosite.cloud 300
Redirect @ (root) https://www.bonlineco.com 300
4. Verify Configuration
# Test DNS resolution
nslookup www.bonlineco.com
dig www.bonlineco.com

# Test redirect
curl -I http://bonlineco.com
# Should return 301/302 to https://www.bonlineco.com
5. After Launch (24-48 hours)
# Increase TTL back to normal
TTL: 3600 seconds (1 hour) for stability

Fastly Configuration

Magento Cloud + Fastly Integration

How It Works:

  1. User visits www.bonlineco.com
  2. DNS resolves to Fastly CDN endpoint
  3. Fastly serves cached content if available
  4. If not cached, Fastly requests from Magento Cloud origin
  5. Fastly caches response and serves to user
  6. Future requests served from Fastly edge servers
Benefits:
  • Performance: Content served from edge servers worldwide
  • Caching: Reduces load on Magento servers
  • Security: DDoS protection and WAF
  • SSL/TLS: Automatic SSL certificate management

Common DNS Providers Setup

Provider-Specific Examples

Cloudflare

# CNAME for www
Type: CNAME
Name: www
Target: prod-abc123xyz.magentosite.cloud
Proxy status: DNS only (gray cloud)
TTL: Auto or 5 minutes

# Page Rule for root redirect
URL: bonlineco.com/*
Setting: Forwarding URL (301 Permanent Redirect)
Destination: https://www.bonlineco.com/$1

AWS Route 53

# CNAME for www
Type: CNAME
Name: www
Value: prod-abc123xyz.magentosite.cloud
TTL: 300

# A record + S3 redirect for root
Type: A
Name: (blank/root)
Value: (S3 bucket IP configured for redirect)
TTL: 300

GoDaddy

# CNAME for www
Type: CNAME
Host: www
Points to: prod-abc123xyz.magentosite.cloud
TTL: 1/2 hour

# Forwarding for root
Type: Forwarding
Domain: bonlineco.com
Forward to: https://www.bonlineco.com
Redirect type: Permanent (301)

Troubleshooting DNS Issues

Common Problems and Solutions

Issue 1: DNS Not Propagating

Symptoms:
  • Changes not visible after hours
  • Some locations see old site, others new
Solutions:
  1. Wait for old TTL to expire (could be 24-48 hours)
  2. Use dig or nslookup to verify changes
  3. Check DNS propagation: whatsmydns.net
  4. Clear local DNS cache: ipconfig /flushdns (Windows) or sudo dscacheutil -flushcache (Mac)

Issue 2: CNAME on Root Domain

Error:

DNS provider won't allow CNAME on root domain

Solution:

Use www subdomain with CNAME, redirect root to www using provider's redirect feature or A record + redirect server.

Best Practices

DNS Configuration Guidelines

Do's

  • Lower TTL 24-48 hours before launch
  • Use CNAME for www subdomain
  • Redirect root domain to www
  • Test DNS resolution before launch
  • Verify SSL certificates work
  • Monitor DNS after launch
  • Increase TTL back after stable
  • Document DNS configuration

Don'ts

  • Don't use CNAME for root domain
  • Don't forget to lower TTL first
  • Don't change DNS without testing
  • Don't keep low TTL permanently (unnecessary DNS traffic)
  • Don't skip redirect from root to www

Exam Tips

Key Points to Remember

  • Before going live: Lower TTL value
  • Why lower TTL: Helps DNS propagate sooner
  • Use CNAME records: Point to Fastly DNS endpoint
  • Root domain limitation: Cannot use CNAME for root (e.g., bonlineco.com)
  • Solution: Redirect root to www subdomain
  • CNAME for www: www.bonlineco.com → Fastly endpoint
  • Fastly role: CDN and edge server for Magento Cloud
  • TTL values: Lower before (300s), normal after (3600s)
  • Propagation time: Depends on old TTL value
  • Root redirect methods: DNS provider redirect, A record + server, ALIAS/ANAME