如何使用裸域使用S3,Cloudfront和Route 53将HTTP重定向到HTTPS? [英] How to redirect HTTP to HTTPS using S3, Cloudfront, and Route 53 using naked domains?

查看:106
本文介绍了如何使用裸域使用S3,Cloudfront和Route 53将HTTP重定向到HTTPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有SSL支持的域(example.com)。尝试从 www.example.com -> https://example.com



尝试访问www.example.com时遇到的错误是:


请求无法满足。



错误请求。


这些URL有效(重定向到 https://example.com




  • example.com

  • http://example.com

  • https://example.com



http://www.example.com 显示该网站不安全,这意味着它不使用证书。






S3



我创建了2个S3存储桶example.com& amp; ; www.example.com(分别为A和B)。存储桶A的静态网站托管已启用指向example.com的网站托管。存储桶B的静态网站托管已将所有请求重定向到example.com。






Cloudfront

我有一个带有2个备用域名(CNAME),example.com和www.example.com的发行版。我在该区域也有SSL证书。






53号公路



我有一个托管区域,带有2个A型别名example.com和www.example.com,它们都指向Cloudfront的发行版(XX.cloudfront.net)

解决方案

您需要由Cloudfront分发您的内容。因此,您的S3存储桶中的内容将在投放之前先通过Cloudfront。您可以在此处找到有关操作方法的信息:


I have a domain (example.com) with SSL support. I am having an issue when trying to redirect a request from www.example.com -> https://example.com.

The error I get when trying to access www.example.com is:

The request could not be satisfied.

Bad request.

These URLs work (redirect to https://example.com)

  • example.com
  • http://example.com
  • https://example.com

http://www.example.com shows that the website is not secure, meaning it does not use the certificate.


S3

I have created 2 S3 buckets example.com & www.example.com (A and B, respectively). Bucket A's Static Website Hosting has enable website hosting pointing to example.com. Bucket B's Static Website Hosting has redirect all requests to example.com.


Cloudfront

I have a distribution with 2 Alternate Domain Names (CNAMEs), example.com and www.example.com. I also have an SSL cert on this dist.


Route 53

I have a hosted zone with 2 A-type aliases, example.com and www.example.com that both point to Cloudfront's distribution (XX.cloudfront.net)

解决方案

You need to have your content being distributed by Cloudfront. So the content from your S3 bucket will go through Cloudfront before being served. You can find info about how to do it here: Using CloudFront with Amazon S3

Then, for the second part, to have all your data served with https, do the following: Go to CloudFront > Your distribution > behaviour tab > select the first element of the list and click Edit. Then you should be able to see an option for redirecting http to https.

这篇关于如何使用裸域使用S3,Cloudfront和Route 53将HTTP重定向到HTTPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆