简体   繁体   English

AWS:使用Route 53和S3存储桶将www重定向到根

[英]AWS : Redirecting www to root using Route 53 and S3 bucket

I have an application that runs on a Elastic BeanStalk under a Classic Load balancer. 我有一个在Classic Load Balancer下在Elastic BeanStalk上运行的应用程序。 I want my site to respond to example.com and also to www.example.com. 我希望我的网站对example.com以及www.example.com做出响应。 I did the following to perform that : 我做了以下操作:

1. Creating an A record to Classic Load Balancer 1.创建A记录到Classic Load Balancer

  • In Route 53, I created a HostedZone called example.com and the created a A record for example.com as an alias to the Classic Load Balancer. 在Route 53中,我创建了一个名为example.com的HostedZone,并为example.com创建了A记录,作为Classic Load Balancer的别名。

This works fine. 这很好。

2. Creating a S3 Bucket for www.example.com 2.为www.example.com创建一个S3存储桶

  • I created a S3 Static web site Bucket named www.example.com that redirects to example.com 我创建了一个名为www.example.com的S3静态网站存储桶,该网站重定向到example.com

This works fine. 这很好。 When I navigate to http://www.example.com.s3-website-us-east-1.amazonaws.com it redirects me to example.com 当我导航到http://www.example.com.s3-website-us-east-1.amazonaws.com时,它会将我重定向到example.com

3. Creating a A record for www.example.com 3.为www.example.com创建A记录

  • I created then a A Alias record named www.example.com to the S3 Bucket and waited for more than 16 hours. 然后,我在S3存储桶中创建了一个名为www.example.com的别名记录,等待了16个小时以上。

This does not work. 这是行不通的。 In Chrome, i have the following error : 在Chrome中,我遇到以下错误:

This site can't be reached www.example.com took too long to respond. 无法访问该网站www.example.com花费的时间太长,无法回复。

What am I missing ? 我想念什么?

PS: I have done nothing for www.example.com in my registrar. 附言:我对注册商中的www.example.com没有做任何事情。 Anything have to be done ? 有什么需要做的吗?

Thank you for your help. 谢谢您的帮助。

在此处输入图片说明

I had similar issue. 我有类似的问题。 What worked for me from discussion in that chat: 通过聊天中的讨论对我有用的是:

  1. make sure that it's reachable via http 确保通过http可以访问
  2. if yes - order an SSL Certificate and use CloudFront to be able to use https 如果是,请订购SSL证书并使用CloudFront能够使用https

if not - configuration of Alias / A-record is incorrect. 如果不是-别名/ A记录的配置不正确。 Then check all permissions (S3 should be available for reading publicly; S3 bucket should be setup as Website Hosting; the bucket name should be identical to the Route 53 hosted zone name). 然后检查所有权限(S3应该可以公开读取; S3存储桶应设置为“网站托管”;存储桶名称应与Route 53托管区域名称相同)。 See all details in official AWS article here . 此处查看AWS官方文章中的所有详细信息。

S3 Website endpoint doesn't support HTTPS so if a user access it on HTTPS, it won't work. S3网站终结点不支持HTTPS,因此,如果用户通过HTTPS访问它,它将无法正常工作。 Creating a CloudFront only for redirection can solve this but increase the work. 仅创建用于重定向的CloudFront可以解决此问题,但会增加工作量。 (CF+ACM+S3+Route53) I would suggest use a redirection rule directly on the beanstalk environment and create alias records for both www.example.com and example.com to point to ELB. (CF + ACM + S3 + Route53)我建议直接在beantalk环境上使用重定向规则,并为www.example.com和example.com创建别名记录以指向ELB。

Here is how you can do that using CloudFront 是使用CloudFront的方法

Directly on Beanstalk 直接在Beanstalk上

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM