简体   繁体   English

建议在 GitHub Pages 上使用“www”域有何意义?

[英]What is with the reccommendation to use `www` domain on GitHub Pages?

If you look at the documentation for GitHub pages, it has a pretty strong reccommendation to use a www domain for your custom domain site hosted on GitHub Pages.如果您查看 GitHub 页面的文档,强烈建议您将www域用于托管在 GitHub 页面上的自定义域站点。

From here: https://help.github.com/en/articles/about-supported-custom-domains#www-subdomains从这里: https : //help.github.com/en/articles/about-supported-custom-domains#www-subdomains

A www subdomain is the most commonly used type of subdomain, in which the www stands for World Wide Web. www 子域是最常用的子域类型,其中 www 代表万维网。 For example, www.example.com is a www subdomain because it contains the subdomain part www.例如,www.example.com 是 www 子域,因为它包含子域部分 www。

We strongly recommend that you use a www subdomain for these reasons:我们强烈建议您使用 www 子域,原因如下:

  • It gives your GitHub Pages site the benefit of our Content Delivery Network.它使您的 GitHub Pages 站点受益于我们的内容交付网络。
  • It is more stable because it is not affected by changes to the IP addresses of GitHub's servers.它更稳定,因为它不受 GitHub 服务器 IP 地址更改的影响。
  • Pages will load significantly faster because Denial of Service attack protection can be implemented more efficiently.页面加载速度会显着加快,因为可以更有效地实施拒绝服务攻击保护。

Does this mean if I do not use a www domain I will not get the benefits of a CDN or DDOS Attack Protection?这是否意味着如果我不使用www域,我将无法获得 CDN 或 DDOS 攻击保护的好处?

What is the technical reason why there is a difference between a www and non- www domain here?此处www和非www域之间存在差异的技术原因是什么?

DNS does not provide a reliable mechanism for forwarding on apex/root records (eg example.com ) but does for subdomains (CNAME). DNS 不提供可靠的机制来转发顶点/根记录(例如example.com ),但为子域(CNAME)提供。 In practice this means that while you can point an A record to a single IP address corresponding to a node on Github's infrastructure, they aren't able to route DNS lookups for your apex record to other IP addresses that are closer to the request (CDN) or use DNS to mitigate the effects of a (D)DoS attack.实际上,这意味着虽然您可以将A记录指向与 Github 基础架构上的节点相对应的单个 IP 地址,但它们无法将您的顶点记录的 DNS 查找路由到更接近请求的其他 IP 地址(CDN ) 或使用 DNS 来减轻 (D)DoS 攻击的影响。

Some DNS providers do offer synthetic records (ALIAS, ANAME) that mimic the behavior of a CNAME record with apex domains (eg dnsimple ), but they're not widely available, introduce additional complexity and latency, and don't provide the same level of geographic routing opportunities to Github et al.一些 DNS 提供商确实提供了模拟 CNAME 记录行为的合成记录(ALIAS、ANAME)(例如dnsimple ),但它们并不广泛可用,引入了额外的复杂性和延迟,并且不提供相同级别Github 等人的地理路由机会。

The difference lies in how you point the site to GitHub's servers in DNS.不同之处在于您如何在 DNS 中将站点指向 GitHub 的服务器。

The simplest use of DNS is to point a domain name, at whatever level, at an IP address, using an A record. DNS 的最简单用途是使用 A 记录将域名指向 IP 地址,无论级别如何。 The same address will be used by all users, and can be changed only by the owner of the "zone" where the A record was added - in this case you, configuring the zone of your custom domain.所有用户都将使用相同的地址,并且只能由添加 A 记录的“区域”的所有者更改 - 在这种情况下,您可以配置自定义域的区域。

A smarter way is to alias a particular domain name to a different zone - in this case one managed by GitHub - using a CNAME record.更聪明的方法是使用 CNAME 记录将特定域名别名到不同的区域 - 在这种情况下由 GitHub 管理。 The owners of that zone can then change the IP address as needed, and can even give different answers to different users based on their location (which is where the CDN reference comes from).然后,该区域的所有者可以根据需要更改 IP 地址,甚至可以根据不同用户的位置(这是 CDN 引用的来源)为不同的用户提供不同的答案。

The key restriction however is that you can't use a CNANE as the root of a zone .然而,关键的限制是您不能使用 CNANE 作为 zone 的根 See this Server Fault question for the technical details.有关技术详细信息,请参阅此服务器故障问题

If you own "example.com", you can point an A record for the root of that domain at one GitHub IP address (or a few, selected essentially at random by visitors), but will give GitHub more freedom to route the traffic if you point a CNAME for a sub-domain, like "www.example.com".如果您拥有“example.com”,您可以在一个 GitHub IP 地址(或几个,基本上由访问者随机选择)指向该域根的 A 记录,但如果您指向子域的 CNAME,例如“www.example.com”。

Some DNS providers offer tools to work around this limitation by adding a fake record for the root of the domain that looks like a CNAME, but may be labelled differently (eg ANAME, ALIAS).一些 DNS 提供商通过为域的根添加假记录来解决此限制,该记录看起来像 CNAME,但可能标记不同(例如 ANAME、ALIAS)。 When asked for the root A record, the DNS provider looks up the actual A records for that domain and returns those.当要求提供根 A 记录时,DNS 提供商会查找该域的实际 A 记录并返回这些记录。 This is useful for records which change over time, but because the address is being looked up by your DNS provider not the actual visitor, it may still prevent GitHub serving the best address for that visitor.这对于随时间变化的记录很有用,但由于地址是由您的 DNS 提供商而不是实际访问者查找的,因此它可能仍会阻止 GitHub 为该访问者提供最佳地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM