将 Amazon CloudFront 指向 A 记录而不是 CNAME

发布于 2024-09-03 17:47:28 字数 190 浏览 4 评论 0原文

我找到了将我的域的 CNAME 指向 Amazon 的 CloudFront 服务的说明,但理想情况下我想指向根名称(A 记录名称)。例如,example.com 而不是 www.example.com。这可能吗?

I've found instructions to point my domain's CNAME to Amazon's CloudFront service but ideally I would like to point the root name (A record name). For example, example.com instead of www.example.com. Is this possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

娜些时光,永不杰束 2024-09-10 17:47:28

您可以使用 Route 53 服务将区域顶点(即 example.com)指向 AWS 上的 CloudFront 分配。只需登录您的 CloudFront 分配并将备用域名 (CNAME) 设置为您的域(例如 example.com 和/或 www.example.com)。然后在 Route 53 中,为您的域创建一个托管区域,然后创建一个别名记录,选择 CloudFront 分配作为目标。您还可以为任何子域创建第二个别名记录,例如 www.example.com。注意:您还需要通过域名注册商更改名称服务器。

来自 53 号公路常见问题解答:

问。我可以将我的区域顶点(example.com 与 www.example.com)指向我的
Amazon CloudFront 分布?

是的。 Amazon Route 53 提供一种称为“别名”的特殊记录类型
记录,可让您将区域顶点 (example.com) DNS 名称映射到您的
Amazon CloudFront 分发(例如 d123.cloudfront.net)。知识产权
与 Amazon CloudFront 终端节点关联的地址因以下因素而异
您的最终用户的位置(以便将最终用户引导至
最近的 CloudFront 边缘位置),并且可能由于以下原因随时更改
放大、缩小或软件更新。 53 号公路响应
每个别名记录请求以及 IP 地址
分配。 Route 53 对别名记录的查询不收费
映射到 CloudFront 分配。列出了这些查询
作为 Amazon Route 53 使用报告中的“Intra-AWS-DNS-Queries”。

有关更多信息,请参阅 AWS 文档:

You can point the zone apex (i.e. example.com) to a CloudFront distribution on AWS using their Route 53 service. Just log into your CloudFront distribution and set the Alternate Domain Names (CNAMEs) to your domain (e.g. example.com and/or www.example.com). Then in Route 53, create a hosted zone for your domain, and then an alias record selecting the CloudFront distribution as the destination. You can also create a second alias record for any sub-domains, such as www.example.com. Note: you'll need to change the name servers with your domain registrar too.

From the Route 53 FAQs:

Q. Can I point my zone apex (example.com versus www.example.com) at my
Amazon CloudFront distribution?

Yes. Amazon Route 53 offers a special type of record called an ‘Alias’
record that lets you map your zone apex (example.com) DNS name to your
Amazon CloudFront distribution (for example, d123.cloudfront.net). IP
addresses associated with Amazon CloudFront endpoints vary based on
your end user’s location (in order to direct the end user to the
nearest CloudFront edge location) and can change at any time due to
scaling up, scaling down, or software updates. Route 53 responds to
each request for an Alias record with the IP address(es) for the
distribution. Route 53 doesn't charge for queries to Alias records
that are mapped to a CloudFront distribution. These queries are listed
as “Intra-AWS-DNS-Queries” on the Amazon Route 53 usage report.

For more information, see AWSs documentation:

浅黛梨妆こ 2024-09-10 17:47:28

仍然可以使用 A 记录来指向 www.example.com,但是您必须将其指向 IP 地址,它与“www”或前面的任何其他内容无关或不。

CNAME 和 A 记录之间的区别仅在于 CNAME 指向另一个名称,该名称必须依次由 DNS 查找,而 A 记录只需要一次查找并直接指向 IP 地址。

也就是说,您很快就会明白为什么在此类云托管中使用 A 记录可能是一个坏主意或不可能。亚马逊使用多个 IP 地址,您不会预先知道这些 IP 地址是什么。 DNS 更改速度很慢。因此,除非您有一个不会更改的特定 IP 地址,否则使用 A 记录根本不起作用。找到具有固定 IP 地址的托管服务,您就可以使用 A 记录。

在性能或可达性方面,CNAME 和 A 记录之间只有微小的差异。

编辑:
正如 SLAks 指出的那样,似乎最好坚持“旧规则”,为根域名使用 A 记录。但您会发现有时您别无选择,具体取决于您的托管提供商允许您做什么。幸运的是,现在几乎没有什么可以阻止您这样做(使用 CNAME)。

Pointing www.example.com can still be done with an A-record, but you have to point it to an IP address then, it has nothing to do with the "www" or anything else in front or not.

The difference between CNAMEs and A-Records is only that a CNAME points to another name, which must in turn be looked up by the DNS, whereas an A-record only requires one lookup and is pointed directly to an IP address.

That said, you quickly understand why using A-records with this type of cloud hosting might be a bad idea or impossible. Amazon uses several IP addresses and you won't know up front what IP addresses these are. DNS changes are slow. So, unless you have a specific IP address that does not change, using an A-record simply will not work. Find a hosting offer with a fixed IP address and you can use A-records.

In terms of performance or reachability, there's only a marginal difference between CNAME and A-records.

EDIT:
As SLaks points out, it seems best to stick to "old rules" to use an A-Record for your root domain name. But you'll find that sometimes you will not have a choice, depending on what your hosting provider allows you to do. Luckily, nowadays, there's little if anything that should practically withhold you from doing so (using CNAME).

鲜肉鲜肉永远不皱 2024-09-10 17:47:28

我们使用cloudfront,并使用route53作为dns。
指向根域的最佳方法是将其设置为 A 记录,然后单击小“别名”滑块。
在新的下拉列表中,选择 cloudfront 作为别名端点。
将出现另一个下拉列表,显示与您管理的区域具有相同根域名的 Cloudfront 存储库。选择它就完成了。

确保在 cloudfront 配置本身中,您拥有裸域的 CNAMES 条目,以及 www 版本域名的第二个条目。

从那里开始,只要您的 Web 服务器设置为接受该域的流量,它就应该可以工作。

We use cloudfront, and we use route53 for dns.
The best way to point the root domain is to set it up as an A record, then click the little "Alias" slider.
In the new dropdowns, choose cloudfront as the alias endpoint.
Another dropdown appears, showing cloudfront repositories that have the same root domain name as the zone you are managing. Select it and you are done.

Make sure that in the cloudfront configuration itself that you have CNAMES entries for both the naked domain, and a second one for the www version of your domain name.

From there it should work as long as your web server is setup to accept traffic for the domain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文