Cloudfront使用ssl将www重定向到裸域 [英] Cloudfront redirect www to naked domain with ssl

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

问题描述

请原谅我是否曾经被问过,有很多资源可以解决这个问题,但是似乎没有什么适合我的特定(https)用例。

Forgive me if this has been asked before, there are a number of resources that touch on this, but nothing seems to fit for my specific (https) use-case.

我正在尝试将 https://www.example.com 重定向到 https://example.com 。同样,这应该适用于 http://www.example.com https://example.com

I'm trying to redirect https://www.example.com to https://example.com. Likewise, this should work for http://www.example.com to https://example.com.

我已经建立了一个以s3为起点的云端分布存储桶,将http重定向到https,添加了cname example.com并添加了我的域证书(适用于www子域以及裸域)。

I have set up a cloudfront distribution with the origin of an s3 bucket, redirect http to https, added the cname example.com and added my domain certificate (which works for the www subdomain as well as the naked domain).

我有还设置了一个单独的发行版,并使用了www.example.com的cname,添加了证书并将源设置为单独的s3存储桶,该存储桶在(静态网站托管)中将所有请求重定向到 https://example.com

I have also set up a separate distribution, with a cname for www.example.com, added the certificate and set the origin to a separate s3 bucket that in (static website hosting) redirects all requests to https://example.com.

重定向对于 http://example.com https://example.com ,但是将http:// s://www.example.com改为 https ://example.com 不会。

Redirection works as expected for http://example.com to https://example.com, however http(s)://www.example.com to https://example.com does not.

在路由53中,我的根域别名是第一个cloudfront分发,而www别名是第二个。

In route 53 I have the root domain aliased to the first cloudfront distribution and www aliased to the second.

推荐答案

由于以下答案,我找到了解决方案: Amazon S3重定向和Cloudfront

I found the solution thanks to this answer: Amazon S3 Redirect and Cloudfront

简而言之:

如果源只是存储桶ID,则Cloudfront不遵守S3中的重定向规则设置。相反,我必须将来源设置为提供的s3静态网站主机名。

Cloudfront does not respect the redirection rules setup in S3 if the origin is just the bucket ID. Instead I had to set the origin to the provided s3 static website host name.

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

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