【问题标题】:AWS naked domain redirect when using CloudFront使用 CloudFront 时的 AWS 裸域重定向
【发布时间】:2019-02-26 08:47:07
【问题描述】:

我正在建立一个静态网站,该网站托管在 S3 上,使用 Certificate Manager 提供的 SSL/TLS 证书,并以 CloudFront 为前端。

我一直在努力寻找权威资源,它可以帮助我了解如何配置各种服务,以便:http://example.comhttp://www.example.comhttps://example.com 都将被重定向到 https://www.example.com

到目前为止,我只提出了一半的答案,包括在没有 CloudFront/TLS 的情况下执行此操作,或者尝试进行反向映射 - www.example.com 到 example.com。 (我正在等待我最近的逆向工程尝试传播,但我不是非常有信心它会起作用。)

我怎样才能做到这一点?

【问题讨论】:

标签: amazon-web-services amazon-s3 amazon-cloudfront amazon-route53


【解决方案1】:

HTTP 到 HTTPS 重定向内置在 CloudFront (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https-viewers-to-cloudfront.html) 中,而将根域重定向到 www 可能更复杂。

一种简单有效的方法是将根域映射到单独的 S3 存储桶(因为存储桶必须与域名匹配),并在存储桶本身内设置重定向(请参阅:https://docs.aws.amazon.com/AmazonS3/latest/user-guide/redirect-website-requests.html)或使用 HTML在 index.html 中重定向。

<meta http-equiv="refresh" content="0; URL='http://www.example.com'" />

回家有帮助!

【讨论】:

  • 谢谢。我相信我正在寻找的解决方案将需要一些额外的粒度(例如证书管理器设置、CloudFront 备用域名、Cloud Front 来源等)。我已经为自己找到了一个可行的解决方案,并将很快回答我自己的问题——除非你想充实你的问题。
猜你喜欢
  • 2020-02-17
  • 2015-04-24
  • 1970-01-01
  • 2012-05-05
  • 2018-10-21
  • 2017-06-02
  • 2020-11-28
  • 1970-01-01
  • 2015-02-27
相关资源
最近更新 更多