Skip to content

Cannot open url with www prefix hosted on AWS

0

I have a AWS Cloudfront distribution accessible at 123456789.cloudfront.net. I want also to access it via domain name. I registered a domain and I added these domain records:

Enter image description here

I added CNAME records to access the website using www.

I can open the website using https://domain1.com but I can open it using https://www.domain1.com.

When I try t open it using doman.com I get:

403 ERROR The request could not be satisfied. Bad request. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner. If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation. Generated by cloudfront (CloudFront) Request ID: wUA5UHO7ZfSJOFW1hvRc332zxtfl07YXWW2qrGgXO519r3plqEwxLA== Do you know what is the correct way to configure the website to be accessible using: https://domain1.com, https://www.domain1.com and domain1.com in Route 53?

asked 10 months ago246 views

2 Answers
0

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:

  1. In your CloudFront distribution settings, go to the "General" tab and edit the distribution.

  2. Add both domain variations to the "Alternate Domain Names (CNAMEs)" field:

  1. Make sure your SSL/TLS certificate in AWS Certificate Manager (ACM) covers both domain names (domain1.com and www.domain1.com).

  2. 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
  1. 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

AWS
EXPERT

reviewed 10 months ago

EXPERT

reviewed 10 months ago

0

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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.