10

I'm trying to Redirect non-www requests to www on Amazon Route 53.

I made an S3 bucket with the name of the naked domain and configure the bucket properties to redirect from example.com to www.example.com, and then in Route 53 create an alias for the naked domain name that points to that S3 bucket based on the following :

Redirect non-www requests to www on Amazon Route 53

It worked great for me, except for the HTTPS.

Right now I can't access https://example.com for some reason.

Any help would be highly appreciated.

Eki Eqbal
  • 211
  • 1
  • 2
  • 6
  • 1
    What is the problem you are having? "some reason" doesn't describe anything. – Michael Hampton Feb 12 '15 at 01:46
  • I am trying to send naked domain traffic to www. I am using Amazon Route53 for DNS. I set up an S3 bucket and an Alias record to route naked domain traffic to www. That is working fine. The issue is that since I serve all content over https, if I go directly to https://example.com the browser cannot establish the necessary connection to the server and therefore doesn't even issue an HTTP request. Therefore I am not redirected to the www domain and instead the request fails. – Eki Eqbal Feb 12 '15 at 01:57
  • @MichaelHampton to summarize, here are the possible scenarios and results: 1: Enter example.com -> successful redirect to https://www.example.com 2: Enter www.example.com -> successful https://www.example.com 3: Enter https://example.com -> ERROR – Eki Eqbal Feb 12 '15 at 02:01
  • 1
    But what is the error?! – Michael Hampton Feb 12 '15 at 02:03
  • The error is that we can't even access the page. As for example Chrome gives "Google Chrome's connection attempt to example.com was rejected. The website may be down, or your network may not be properly configured." – Eki Eqbal Feb 12 '15 at 02:07
  • Are your DNS A records correctly configured for both domains? – Tero Kilkanen Feb 12 '15 at 09:33

2 Answers2

4

Quite simply, you can't do what you are trying to do with S3, because the S3 web site endpoints offered by S3 do not support https.

DNS can't redirect web browsers, of course, so Amazon has a simple solution that leverages an S3 bucket with no content, and just a blanket redirect to another domain, as a helper mechanism to allow Route 53 to accomplish the task of redirecting the browser.

But the example.com → www.example.com redirection capability of S3 is http only.

Michael - sqlbot
  • 21,988
  • 1
  • 57
  • 81
  • Thanks for your help. Is there any workaround for this? I mean I'm sure I can do something here. How about @imperalix comment and using CloudFront to terminate the s3 bucket ? – Eki Eqbal Feb 12 '15 at 15:57
  • @EkiEqbal @imperialix is correct, you could use Cloudfront, assuming your visitors are using modern browsers with SNI capability. You'd also need to [configure Cloudfront](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html) to pass the `Host:` header to the origin, and you'd have to use the S3 website endpoint as a custom origin, not as what Cloudfront calls an "S3 origin" (since that doesn't hit the web site endpoint). – Michael - sqlbot Feb 12 '15 at 19:50
4

You can put CloudFront in front of your s3 bucket and have CloudFront terminate the SSL connection. HTTPS is free when using SNI.

Steps:

  • create distribution and configure ssl, with the origin being your s3 website redirect bucket.
  • set the cname to be your naked domain
  • update route 53 to point to this distribution
Andrew Schulman
  • 8,561
  • 21
  • 31
  • 47
imperalix
  • 344
  • 2
  • 4
  • Thanks for your willing to help man as we've been struggling with this recently. Can you explain more please or at least provide a link to show how to implement that as it's not that simple :) – Eki Eqbal Feb 12 '15 at 15:55
  • 1
    http://stackoverflow.com/a/24876361/1074480 does a good job of going into more details. Let me know if these steps don't work for you. – imperalix Feb 14 '15 at 01:02