静态 GCS 网站存储桶和 http 根域不起作用

Static GCS Website bucket and http root domain not workiing

我创建了一个 GCS 存储桶 www.example.com 并使用我的 DNS 提供商 (DNSimple) 设置了一个 CNAME 记录以指向 c.storage.googleapis.com。我现在可以使用 www 访问我的域,但也想使根域指向存储桶。通读同一主题的线程,这似乎可以通过合成记录(google 域)或 ALIAS 记录(其他 dns 提供商)实现。我似乎无法让它与 DNSimple 一起工作,所以想知道是否有人能发现我的错误?

访问根域时出现以下错误:

<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist.</Message>
</Error>

我将我的 ALIAS 记录设置为将我的根域 example.com 指向 www.example.com,但仍然没有成功。所以基本上是以下两条记录:

ALIAS   example.com www.example.com
CNAME   www.example.com c.storage.googleapis.com

我是不是遗漏了什么或者这是 DNSimple 的限制,因为这显然适用于 Google 域(在阅读其他问题后)?

只是添加来自 Google 文档的位,其中说明相同:

Note: DNS does not support creating a CNAME record on a root domain, such as example.com, so in most cases, you must create your CNAME record on a subdomain, such as www.example.com or myblog.example.com. Some DNS providers offer a non-standard feature that allows a root domain to be aliased to another name without the use of CNAME. Consult your DNS provider documentation to determine if such a feature is available.

我对 GCS 不是很熟悉,因为我曾将 AWS 用于相同的目的。但是,有一些建议:

  1. 确保verify the domain
  2. 确保您的 www 和 apex 都与 bucket/configuration 相关联。这通常是缺少的步骤。 www.example.comexample.com 是两个不同的主机名,如果您将两个 DNS 记录都指向 Google 但您在 Google 帐户中仅配置 www.example.com,则 apex 获胜不工作(这可能是您的情况)。

最后,我建议您将 ALIAS 配置为指向目标 (c.storage.googleapis.com) 而不是 www 本地主机名。

这比我想象的要简单。我没有添加 ALIAS 记录,而是添加了一个指向 example.com at http://www.example.com 的 URL 记录来使重定向工作。