顶级域名上的 Cloudfront dist

发布于 2024-08-03 19:55:43 字数 164 浏览 4 评论 0原文

是否可以将像 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 技术交流群。

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

发布评论

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

评论(4

魄砕の薆 2024-08-10 19:55:43

正如@dgeske 所解释的,这是可以做到的。
就我而言,我没有从 Route 53 购买域名,因此必须进行额外的配置。

场景:您有以下

  1. 云前端分配
  2. 不是从 Amazon Route 53 购买的二级域名 (example.com)。在我的例子中,它是 Google 域名,但这个想法也适用于其他提供商。
  3. 您希望将二级域 (example.com) 指向云前端分配(而不是像 www.example.com 这样的子域。 example.com

您的命名法稍微不准确。 example.com 不是 TLD(顶级域),而是所谓的二级域。请参见下图。
部分内容a URL

执行此操作的步骤。

  1. 在 Route 53 中创建托管区域。在路由 53 中创建托管区域
  2. 路由 53 现在将为您提供名称服务器列表您必须在您购买域名的提供商的域名设置面板中进行设置(在我的例子中是 Google 域名)。从 google 域仪表板更改名称服务器
  3. 返回 Route 53 仪表板,并创建一个 A -此托管区域的别名记录(使用创建记录集选项)。请记住选择“是”单选按钮。A-Alias 记录集确保将子域部分留空(因为我们只对为二级域创建记录感兴趣)。将子域部分留空

现在您应该能够通过 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 服务器来解析名称)
firefox DNS通过 https

您还可能会收到 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

  1. Cloud front distribution
  2. A second-level domain (example.com) not purchased from Amazon Route 53. It was Google domains in my case, but the idea will work for other providers also.
  3. You want to point the second-level domain (example.com) to the cloud front distribution (as opposed to a subdomain like www.example.com)

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.
Parts of a URL

Steps to do this.

  1. Create a hosted zone in Route 53.Create a hosted zone in route 53
  2. Route 53 will now give you a list of name servers that you have to set in the domain settings panel of the provider from which you purchased the domain (Google domains in my case).Chaning name servers from google domains dashboard
  3. Go back to Route 53 dashboard, and create an A - Alias record for this hosted zone (use create record set option). Remember to select 'Yes' radio button.A-Alias record setMake sure you leave the subdomain part empty (since we are only interested in creating record for second-level domain).leave sub-domain part empty

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's DNS over https feature for this. This makes firefox use cloudflare's (not cloudfront) DNS servers. You can also use dig command line utility dig @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)
firefox DNS over https

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 visit http://example.com the file http://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 to http://abcd.cloudfront.net directly, instead of going to http://example.com).

遥远的她 2024-08-10 19:55:43

问。我可以将我的区域顶点(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

梦在深巷 2024-08-10 19:55:43

我的理解是您无法为 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.

深海夜未眠 2024-08-10 19:55:43

如果你在cloudfront中添加别名就可以
然后选择 A 或 AAAA(如果在 Cloudfront 上启用了 ipv6)

you can if you add alias in cloudfront
then select A or AAAA(ipv6 if enabled on cloudfront)

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