Serverless-stack-com: Comments: Set up WWW Domain Redirect

Created on 10 Apr 2017  路  12Comments  路  Source: AnomalyInnovations/serverless-stack-com

Most helpful comment

I solved my problem: When I originally set up the the cloudfront distribution, I used the _drop-down_ to chose the origin. The origin was then set to "www-xxx-notes-app-client.s3.amazonaws.com". However, when I went back to check the url for the s3 bucket, it is actually "www-xxx-notes-app-client.s3-website-us-east-1.amazonaws.com" (note the region!). Copying the correct url solved the problem. I'm curious to know if anyone have a guess why the drop-down gives me options that do not work...

All 12 comments

Rather than create a second CloudFront Distribution, why not just add the alias www.[my-domain].com to the Route53 Record Sets for [my-domain]--pointing to the first distribution--then add www.[my-domain].com to that first distribution's Alternate Domain Names? That seems to work fine. Am I missing something?

@pjamieson The reason we set up a redirect on our alternate domain is for SEO purposes. Not necessarily for ranking but because we don't want two versions of our domain active. By re-directing one (the www or apex domain) to the other we are telling the search engines to use one as opposed to both. I hope that makes sense.

Thanks, @jayair. That makes sense.

I'm getting the following error on this step, com.amazonaws.services.cloudfront.model.CNAMEAlreadyExistsException: One or more of the CNAMEs you provided are already associated with a different resource. (Service: AmazonCloudFront; Status Code: 409; Error Code: CNAMEAlreadyExists; Request ID: e21a6bde-c6d7-11e7-9415-837f645450a5), any ideas?

My bucket name is definitely different, so not sure...

@x11joe This usually has to do with a CloudFront distribution having a CNAME already listed as the one you are trying to add. On which screen are you seeing this?

I am seeing this on the part where you say ... Scroll down to the Alternate Domain Names (CNAMEs) and use the www version of our domain name here.

It shows up at the bottom, I'll try and get a screenshot.

....

Well... this is going to sound stupid but I tried just now and its working all the sudden?? Maybe this happened because I was doing test with the domain name prior on another serverless tutorial and it takes like 24 hours for it to remove it's self? Not sure. Maybe this post will help someone.

@x11joe Yeah this can happen. Both the domain setting part and the CloudFront distributions take some time to apply their changes.

I just registered a domain (let's call it "mysite.com") and it shows the Notes app correctly. The s3 url and the cloudflare distribution url also show the Notes app. When trying to get the redirect from www.mysite.com to work, I get the following behavior:

http://www-xxx-notes-app-client.s3-website-us-east-1.amazonaws.com redirects correctly to mysite.com. However, http://www.mysite.com/ and xxx.cloudfront.net (which is the www cloudfront distribution url) both give

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
  <Code>AccessDenied</Code>
  <Message>Access Denied</Message>
  <RequestId>xxx</RequestId>
  <HostId>xxx</HostId>
</Error>

I have looked through the settings of the s3 redirect bucket, the www cloudfront distribution and the hosted zone record sets and they seem correct. Any ideas what to do?

I solved my problem: When I originally set up the the cloudfront distribution, I used the _drop-down_ to chose the origin. The origin was then set to "www-xxx-notes-app-client.s3.amazonaws.com". However, when I went back to check the url for the s3 bucket, it is actually "www-xxx-notes-app-client.s3-website-us-east-1.amazonaws.com" (note the region!). Copying the correct url solved the problem. I'm curious to know if anyone have a guess why the drop-down gives me options that do not work...

@johnnybigert Yeah I've come across this before. I really don't know why it is that way...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jayair picture jayair  路  20Comments

jayair picture jayair  路  15Comments

jayair picture jayair  路  11Comments

jayair picture jayair  路  4Comments

jayair picture jayair  路  14Comments