I have my website setup on S3 and fronted with CloudFront. Everything works out well as far as hosting and such is concerned, but I'm having some weird issues when it comes to redirecting https://www.example.com to https://example.com.
I've setup the site to be rooted at example.com. I have two S3 buckets, one for the root domain (i.e. example.com) and one for www.example.com. The main content is hosted in the example.com bucket, while the www bucket is empty.
The www S3 bucket is setup to redirect all requests to go to the example.com domain. I have cleared the protocol field so that it will match the original request. The redirect domain just says example.com.
The policy for the www bucket is pretty basic, but I'm including it here for completeness:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "2",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::cloudfront:user/..."
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.example.com/*"
}
]
}
What ends up happening is that I can successfully redirect http://www.example.com to https://example.com, but https://www.example.com/simply hangs. Checking this out in curl just causes a timeout.
On the CloudFront side, I have my CF distribution setup with example.com as the alternate domain, and my Origin only points to my example.com bucket.
I use Route53 for DNS, and the www.example.com A record points to the www S3 bucket, while the A record for example.com points to the CloudFront distribution.
I'm at a complete loss here and any help would be appreciated.