如何在 Google Cloud Storage 上托管整个网站? [英] How to host an entire site on Google Cloud Storage?

查看:32
本文介绍了如何在 Google Cloud Storage 上托管整个网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Google Cloud Storage 上托管整个网站?即,将桶直接映射到顶级域.

例如创建一个名为 mysite.com 的存储桶,然后当用户访问 mysite.com 时直接从云存储中提供内容?

我了解如何CNAME 子域,例如静态.mysite.com,但不知道如何将顶级域映射到存储桶.

有什么解决办法吗?

解决方案

我也想这样做.但正如您所发现的,目前无法将 Google Cloud Storage 存储分区直接绑定到顶级域名.

Google Cloud Storage 响应网络请求的 IP 地址经常变化(以适应互联网上不断变化的条件),因此 Google 不希望您将其中的一个子集(很快会过时)添加为 A您网站的 DNS 服务器的记录.相反,Google 需要对其控制的 DNS 名称使用 CNAME,因此它可以根据需要随时更改 Google Cloud Storage 的 IP 地址.并且 CNAME 只能添加到子域,不能添加到顶级域.(这是因为当在给定级别存在 CNAME 时,该域的 DNS 服务器将不会回答该级别的任何其他查询.但顶级域至少还需要回答 NS 和 SOA 查询.)

目前唯一的解决方法是,如另一个答案中所述,为 www 子域设置 CNAME,并配置您的 DNS 托管服务以执行从顶级域到 www 的 http 级重定向子域.(大多数提供商都会支持这一点.)

如果您不喜欢这个解决方案(像我一样),那么只有三种可能性.第一个是等待 Google 提供在 Google Cloud Storage 上托管顶级域的可能性.不过,这首先需要 Google 进行 DNS 托管.启用顶级域支持需要谷歌方面的额外工作(在构建他们的 DNS 托管服务之后),但只有当谷歌控制这两个部分时才有可能.不过,我不知道 Google 是否或何时会提供该服务.但人们可以抱有希望.

第二种解决方案是切换到另一家大供应商.Amazon 可以在顶级域上托管来自 S3 的静态网站.但那是因为他们还为该域托管 DNS.可能还有其他人.所有大型云提供商都将从一组频繁变化的 IP 地址提供数据.因此,如果他们也没有托管您的 DNS,他们将需要您在子域上设置 CNAME.

第三个(至少是理论上的)解决方案是切换到较小的云提供商,提供等效的服务,可能在 OpenStack 等上.因为它们较小,所以它们的 IP 路由设置将比大的简单得多玩家(亚马逊、谷歌等),然后他们将能够为您提供一小组 IP 地址,以在您的顶级域中设置为 A 记录.不过,这只是我有根据的猜测.我现在不知道有任何这样的小型云存储提供商.

(好吧,第四种可能性是放弃静态托管网站的想法.但就个人而言,我真的很喜欢这个选项,至少从安全性和响应性的角度来看是这样.)

Is there any way to host an entire site on Google Cloud Storage? That is, map a bucket directly to a top level domain.

E.g. create a bucket called mysite.com, then when the user visits mysite.com serve the content directly from cloud storage?

I see how to CNAME a subdomain, e.g. static.mysite.com, but can't figure out how to map the top-level domain to a bucket.

Any solution?

解决方案

I wanted to do this too. But there is currently no way of binding Google Cloud Storage buckets directly to a top-level domain name, as you found out.

The IP addresses where Google Cloud Storage answers web requests change often (to adapt to changing conditions on the Internet), so Google doesn't want to you add a subset of those (which would quickly get out of date) as A records for the DNS server of your website. Google instead requires a CNAME to a DNS name it controls, so it can change the IP addresses for Google Cloud Storage as often as it needs to. And a CNAME can only be added to a subdomain and not a top-level domain. (This is because when there is a CNAME at a given level, the DNS server for that domain will not answer any other queries for that level. But a top-level domain needs to answer also at least NS and SOA queries.)

The only workaround for this right now is, as described in another answer, to set up the CNAME for the www subdomain, and configure your DNS hosting service to do a http-level redirect from the top-level domain to the www subdomain. (Mosty providers will support that.)

If you're not a fan of this solution (like me), there are exactly three possibilities. The first one is to wait for Google to offer the possibility to host top-level domains on Google Cloud Storage. That requires Google to DNS hosting, first though. Enabling top-level domain support would require extra work on Google's part (after building their DNS hosting offering), but it's only possible if Google controls both parts. I have no clue if or when Google will ever offer that, though. But one can hope.

The second solution is to switch to another big provider. Amazon can host static websites from S3 on a top-level domain. But that's because they also host DNS for that domain. There may be others. All large cloud providers will serve data from a set of frequently-changing IP addresses. So if they don't host your DNS too, they will need you to set a CNAME on a subdomain.

The third (theoretical, at least) solution is to switch to a smaller cloud provider, offering equivalent service, maybe on OpenStack, etc. Because they're smaller, their IP routing setup will be quite a bit simpler than the big players (Amazon, Google, etc.) and they would then be able to give you a small set of IP addresses to set as A records on your top-level domain. This is just an educated guess on my part, though. I don't know right now of any such smaller cloud storage providers.

(Well, okay, the fourth possibility is to give up on the idea of hosting your website statically. But personally, I really like this option when possible, at least from a security and responsiveness point of view.)

这篇关于如何在 Google Cloud Storage 上托管整个网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆