【发布时间】:2021-10-15 14:24:40
【问题描述】:
要求
在以下所有要求中,URL 应在浏览器中更改
- firstdomain.com 应该被重定向到https://sub.seconddomain.com
- http://firstdomain.com 应该被重定向到 https://sub.seconddomain.com
- https://firstdomain.com 应该被重定向到 https://sub.seconddomain.com
参考文件
-
https://aws.amazon.com/premiumsupport/knowledge-center/route-53-redirect-to-another-domain/我在这个例子中采用了这种方法
-
Set up DNS based URL forwarding in Amazon Route53 惊人的解决方案,但不适用于第三种情况,即https://firstdomain.com
我的 S3 配置
- S3 存储桶名称:firstdomain.com
- 启用静态网站托管,以下是配置
- 协议:https
- 将请求重定向到:sub.seconddomain.com
CloudFront 配置
- 来源名称:firstdomain.com.s3-website.ap-south-1.amazonaws.com
- 查看器协议策略:将 HTTP 重定向到 HTTPS
- 备用域名:firstdomain.com 和 seconddomain.com
- ACM 证书:与 *.firstdomain.com 和 *.seconddomain.com 一起安装
- 注意到云端名称是:something.cloudfront.net
Route53 配置
- 别名 Ipv4 记录创建于 firstdomain.com -> something.cloudfront.net
发生了什么
- firstdomain.com 重定向到http://sub.seconddomain.com
- http://firstdomain.com。重定向到http://sub.seconddomain.com
- https://firstdomain.com 重定向到 http://sub.seconddomain.com
所以我的所有请求都被强制移动到 http 并且没有加载证书。
以下是卷曲输出
$ cat curloutput.txt| egrep -i "location|server|301"
< HTTP/1.1 301 Moved Permanently
< Server: CloudFront
< Location: https://firstdomain.com/
* Connected to firstdomain.com (someIP) port 443 (#1)
* successfully set certificate verify locations:
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* ALPN, server accepted to use h2
* Server certificate:
* issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
* Using HTTP2, server supports multi-use
< HTTP/2 301
< location: http://sub.seconddomain.com/
< server: AmazonS3
< x-cache: Hit from cloudfront
* Connected to sub.seconddomain.com (someip) port 80 (#2)
> GET / HTTP/1.1
> Host: sub.seconddomain.com
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Thu, 12 Aug 2021 07:47:58 GMT
< Content-Length: 19
<
【问题讨论】:
标签: amazon-s3 url redirect amazon-cloudfront amazon-route53