在不使用 CNAME 的情况下将子域从 Route53 指向 CloudFront

Point a subdomain from Route53 to CloudFront without using CNAME

我有一个子域 (dev.example.com),我需要将它指向我的云端分发 (xyz.cloudfront.net)。我做了以下步骤

1) 创建了云端分发。创建云端分发时未在 Cname 字段中指定任何内容。

2) 在 Route53 中创建了一个带有 'A' 记录的别名记录并将 dev.example.com 指向 xyz.cloudfront.net。

但是这个设置不起作用。仅当我在云端分发中指定 cname 字段时它才有效。

有什么想法可以使它正常工作吗?

你可以这样做,

Dedicated IP Custom SSL feature

Cloudfront POP 的专用 IP 地址需要 600 美元。

更多详情here

获得专用 IP 后,您可以在 DNS 中创建指向这些 IP 地址的 A 记录。

Cloudfront 基于 SNI(服务器名称指示)工作,需要 CNAME 将您的分发映射到。

希望对您有所帮助。

*.cloudfront.net URL 以外的任何地方访问 CloudFront 分配时,您必须指定 CNAME。即使您使用的是 A 记录。

您正在 Route 53 中创建 ALIAS 记录。即使您没有创建 CNAME 记录,您也必须在 CNAME 分配的字段。

否则,CloudFront 将不知道您请求的分配。

另一种方法是使用专用 IP 地址,但这将花费你 600 美元。

除非您只打算使用 CloudFront 域名,否则如果您希望 CloudFront 为这些域提供服务,则必须在备用域名框中包含一个或多个自定义域名,例如 dev.example.com。

CloudFront 在其配置顺序中需要 so-called CNAME 条目(备用域名)以将传入请求与分配相关联,因此,它们必须是全局唯一的。

但是,似乎与单个子域冲突的通配符是一个例外……它们不会。

如果您使用的是子域,应该可以通过像这样配置两个分配来解决 CloudFront 对备用域名分配的限制:

blue:  dev.example.com
green: *.example.com

将 dev.example.com 的 DNS 记录指向 green 的 CloudFront 端点。 (不要抢在我前面...)

您会发现,尽管有 DNS 设置,blue 端仍会处理 dev.example.com 请求,因为 CloudFront 实际上不知道或不关心请求是如何路由的对它——它使用 SNI 和 Host header 到 select 正确的分布。无论中间路由使用哪个 DNS 记录,dev.example.com 的请求都将匹配蓝色。

要将流量切换为绿色,请从蓝色中删除备用域名,绿色的通配符将自动开始承载流量。无需更改 DNS。

这是记录在案的行为:

You cannot add an alternate domain name to a CloudFront distribution if the alternate domain name already exists in another CloudFront distribution, even if your AWS account owns the other distribution.

However, you can add a wildcard alternate domain name, such as *.example.com, that includes (that overlaps with) a non-wildcard alternate domain name, such as www.example.com. Overlapping domain names can be in the same distribution or in separate distributions as long as both distributions were created by using the same AWS account. (emphasis added)

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html#alternate-domain-names-restrictions