如何在Google Cloud Storage上托管整个网站? [英] How to host an entire site on Google Cloud Storage?
问题描述
是否可以在 Google Cloud Storage 上托管整个网站?也就是说,将存储桶直接映射到顶级域。
Is there any way to host an entire site on Google Cloud Storage? That is, map a bucket directly to a top level domain.
例如创建一个名为 mysite.com 的存储桶,然后当用户访问 mysite.com 时直接从云存储中提供内容吗?
E.g. create a bucket called mysite.com, then when the user visits mysite.com serve the content directly from cloud storage?
我了解如何 CNAME
子域,例如 静态 .mysite.com ,但无法弄清楚如何将顶级域映射到存储桶。
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.
有解决方案吗?
推荐答案
我也想这样做。但是,您发现,目前尚无法将Google Cloud Storage存储桶直接绑定到顶级域名。
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.
Google Cloud Storage回答网络的IP地址请求经常更改(以适应Internet上不断变化的条件),因此Google不想您添加其中的一部分(很快就会过时)作为网站DNS服务器的A记录。 Google要求CNAME为其控制的DNS名称,因此它可以根据需要多次更改Google Cloud Storage的IP地址。而且CNAME只能添加到子域,而不能添加到顶级域。 (这是因为在给定级别上存在CNAME时,该域的DNS服务器将不会回答该级别的任何其他查询。但是顶级域也需要至少回答NS和SOA查询。)
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.)
如另一个答案所述,目前唯一的解决方法是为www子域设置CNAME,并配置DNS托管服务以执行http级从顶级域重定向到www子域。 (有信誉的提供商会为此提供支持。)
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.)
如果您不喜欢这种解决方案(像我一样),则完全有三种可能性。第一个是等待Google提供在Google Cloud Storage上托管顶级域的可能性。但这首先需要Google到DNS托管。启用顶级域支持需要在Google的一部分上进行额外的工作(在构建DNS托管产品之后),但是只有在Google同时控制这两个部分的情况下,才有可能。不过,我不知道Google是否或何时会提供。但是人们可以希望。
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.
第二种解决方案是切换到另一家大型提供商。 Amazon可以在顶级域上托管来自S3的静态网站。但这是因为它们还为该域托管DNS。可能还有其他。所有大型云提供商都将通过一组经常更改的IP地址为数据提供服务。因此,如果他们也没有托管您的DNS,他们将需要您在子域上设置CNAME。
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.
第三个(至少是理论上)的解决方案是切换到较小的云提供商,也许在OpenStack等上提供同等服务。由于它们较小,因此IP路由设置将比大型公司(亚马逊,谷歌等)简单得多,这样他们就可以为您提供一小部分IP地址,以将其设置为顶级域上的A记录。不过,这只是我的有根据的猜测。我现在不知道任何这样的小型云存储提供商。
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屋!