- Newest
- Most votes
- Most comments
The issue you're experiencing is that your CloudFront distribution is not configured to accept requests from the www subdomain. When you set up a CloudFront distribution to work with a custom domain, you need to add all domain variations you want to use as "Alternate Domain Names" (CNAMEs) in your CloudFront distribution settings.
Here's how to fix the issue:
-
In your CloudFront distribution settings, go to the "General" tab and edit the distribution.
-
Add both domain variations to the "Alternate Domain Names (CNAMEs)" field:
- domain1.com
- www.domain1.com
-
Make sure your SSL/TLS certificate in AWS Certificate Manager (ACM) covers both domain names (domain1.com and www.domain1.com).
-
In Route 53, ensure you have proper records for both the root domain and www subdomain:
- For domain1.com: Create an A record as an alias pointing to your CloudFront distribution
- For www.domain1.com: Create either a CNAME record pointing to your CloudFront domain or an A record as an alias pointing to your CloudFront distribution
- For redirecting HTTP to HTTPS, make sure your CloudFront distribution is configured to redirect HTTP requests to HTTPS.
The 403 error you're seeing is specifically because your CloudFront distribution doesn't recognize www.domain1.com as a valid alternate domain name. Once you add it to your CloudFront configuration, the error should be resolved.
Sources
Route 53 subdomain not working with CloudFront | AWS re:Post
HTTP 403 status code (Permission Denied) - Amazon CloudFront
My site doesn't shows up when using the domain name | AWS re:Post
answered 10 months ago
CloudFront only serves requests for hostnames listed under Alternate Domain Names (CNAMEs) in the distribution settings. Your 403 error for www.domain1.com means that hostname isn’t configured in CloudFront or covered by the associated SSL/TLS certificate. In the CloudFront console, open your distribution, choose Edit, and under Alternate Domain Names (CNAMEs) add both domain1.com and www.domain1.com. Then attach an ACM certificate in the same AWS Region (us-east-1 for CloudFront) that includes both names in its Subject Alternative Names.
In Route 53, create two alias records pointing to the CloudFront distribution—one for the root domain (`domain1.
—Taz
answered 10 months ago
