顶级域名上的 Cloudfront dist
是否可以将像 http://example.com 这样的顶级域名指向亚马逊云前端发行版?
我知道可以使用 CNAME,但据我所知,我需要在 DNS 设置中为顶级域设置 A 名记录。
Is it possible to point a top level domain like http://example.com to a amazon cloudfront distribution?
I know it's possible with CNAMEs, but as far as I know, I need to set an A-name record for the top level domain in the DNS settings.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如@dgeske 所解释的,这是可以做到的。
就我而言,我没有从
Route 53
购买域名,因此必须进行额外的配置。场景:您有以下
您的命名法稍微不准确。 example.com 不是 TLD(顶级域),而是所谓的二级域。请参见下图。
执行此操作的步骤。
现在您应该能够通过
http://example.com
访问您的 cloudfront 发行版。根据您的 DNS 服务器的不同,可能需要一段时间才能更新记录。
您可以将系统配置为使用公共 DNS 服务器(例如
8.8.8.8
)来验证您是否能够使用 URL 访问 cloudfront 发行版。为此,我使用了 Firefox 的DNS over https
功能。这使得 Firefox 使用 cloudflare(不是 cloudfront)的 DNS 服务器。您还可以使用 dig 命令行实用程序dig @8.8.8.8 example.com
(我的域名是 Fightcoronapune.com,因此dig @8.8.8.8 Fightcoronapune.com
)(告诉 dig 使用 8.8.8.8 DNS 服务器来解析名称)您还可能会收到
Access Denied
错误,在这种情况下,您必须为您的 Cloudfront 发行版配置默认根对象。这样,当您访问http://example.com
时,就会向您提供文件http://example.com/index.html
(假设您指定了 index.html作为默认根对象)。 此错误与我们上面执行的步骤无关,即使您直接使用 Amazon 提供的 Cloudfront 发行版 URL(例如,当您直接访问http://abcd.cloudfront.net
,而不是访问http://example.com
)。As explained by @dgeske, this can be done.
In my case, I had not purchased the domain from
Route 53
, and hence had to do extra configuration.Scenario: You have the following
Your nomenclature is slightly inaccurate. example.com is not a TLD (top-level domain), it is what is called a second-level domain. See the following image.
Steps to do this.
Now you should be able to access your cloudfront distribution at
http://example.com
.Depending on your DNS server, it may take a while to get records updated.
You may configure your system to use a public DNS server such as
8.8.8.8
to verify if you are able to access the cloudfront distribution using the URL. I used firefox'sDNS over https
feature for this. This makes firefox use cloudflare's (not cloudfront) DNS servers. You can also use dig command line utilitydig @8.8.8.8 example.com
(My domain was fightcoronapune.com, hence,dig @8.8.8.8 fightcoronapune.com
) (telling dig to use 8.8.8.8 DNS server to resolve names)You may additionally get
Access Denied
error, in which case you will have to configure the default root object for your cloudfront distribution. So that when you visithttp://example.com
the filehttp://example.com/index.html
is served to you (assuming you specified index.html as default root object). This error has nothing to do with the steps we did above, and you will still get this error even if you directly use your cloudfront distribution's URL given by Amazon (eg. when you go tohttp://abcd.cloudfront.net directly
, instead of going tohttp://example.com
).问。我可以将我的区域顶点(example.com 与 www.example.com)指向我的 Amazon CloudFront 分配吗?
可以。 Amazon Route 53 提供一种称为“别名”记录的特殊类型记录,可让您将区域顶点 (example.com) DNS 名称映射到您的 Amazon CloudFront 分配(例如 d123.cloudfront.net)。与 Amazon CloudFront 终端节点关联的 IP 地址因最终用户的位置而异(以便将最终用户引导到最近的 CloudFront 边缘位置),并且可能因扩展、缩小或软件更新而随时发生变化。 Route 53 使用用于分发的 IP 地址响应每个别名记录请求。 Route 53 不会对映射到 CloudFront 分配的别名记录的查询收费。这些查询在 Amazon Route 53 使用报告中列为“Intra-AWS-DNS-Queries”。
资料来源:Amazon Route 53 常见问题解答
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.
Source: Amazon Route 53 FAQs
我的理解是您无法为 Cloudfront 创建 A 记录。
Amazon 为您提供了一个域名,例如 YourName.cloudfront.net。他们需要在后台管理该域名的 DNS 解析,以便将每个请求路由到最近的边缘服务器。
My understanding is that you cannot create an A record for Cloudfront.
Amazon provides you with a domain name like YourName.cloudfront.net. They need to manage the DNS resolution for that domain name behind the scenes in order to route each request to the nearest edge server.
如果你在cloudfront中添加别名就可以
然后选择 A 或 AAAA(如果在 Cloudfront 上启用了 ipv6)
you can if you add alias in cloudfront
then select A or AAAA(ipv6 if enabled on cloudfront)