AWS S3 CloudFront - 从 https://www.domain.com 重定向到 https://domain.com [英] AWS S3 CloudFront - redirect from https://www.domain.com to https://domain.com

查看:38
本文介绍了AWS S3 CloudFront - 从 https://www.domain.com 重定向到 https://domain.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的 AWS Route 53 设置:

Here is my AWS Route 53 Setup:

https://www.migranthire.com 不起作用.我如何从此域重定向到 https://migranthire.com

The domain https://www.migranthire.com doesn't work. How can i redirect from this domain to https://migranthire.com

推荐答案

您的 www 站点直接指向 S3 存储桶网站托管端点,该端点负责重定向到域名没有 www 前缀.

Your www site is pointing directly to an S3 bucket web site hosting endpoint, which is taking care of the redirect to the domain name without the www prefix.

S3 网站端点不支持 HTTPS,因此这适用于仅限 http.

The S3 website endpoints do not support HTTPS, so this works for http only.

您的解决方案是创建第二个 CloudFront 分配——您需要一个额外的分配,因为第二个分配有不同的来源.使用您的 SSL 证书配置此分配,配置为期望 www 主机名作为替代名称,并将其来源设置为 www 存储桶——但是,当您设置第二个 CloudFront 分配时,不要从列表中选择您的存储桶名称.而是输入网站端点主机名 - www.migranthire.com.s3-website-eu-west-1.amazonaws.com.将源协议设置为仅 HTTP(即使查看器协议是 HTTPS,CloudFront 也必须将请求作为 HTTP 发送到存储桶.您仍然会获得绿色锁.)

Your solution is to create a second CloudFront distribution -- you need an additional one, because the second one has a different origin. Configure this distribution with your SSL certificate, configured to expect the www hostname as an alternative name, and set its origin to the www bucket -- however, when you are setting up this second CloudFront distribution, do not select the name of your bucket from the list. Instead, enter the website endpoint hostname -- www.migranthire.com.s3-website-eu-west-1.amazonaws.com. Set the origin protocol to HTTP only (CloudFront has to send the request to the bucket as HTTP even if the viewer protocol is HTTPS. You still get a green lock.)

然后,配置 Route 53 以将 www 请求发送到新的 CloudFront 分配,而不是直接发送到存储桶.CloudFront 将使用 SSL,将请求发送到 S3,S3 将返回重定向,就像现在一样.

Then, configure Route 53 to send www requests to the new CloudFront distribution, instead of directly to the bucket. CloudFront will speak SSL, sent the request to S3, which will return the redirect, as it is doing now.

这篇关于AWS S3 CloudFront - 从 https://www.domain.com 重定向到 https://domain.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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