如何为Google Cloud Functions配置自定义域以呈现HTML [英] How to configure custom domain for Google Cloud Functions for rendering HTML

查看:54
本文介绍了如何为Google Cloud Functions配置自定义域以呈现HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我已经将Google Cloud Function部署到了这样的某个地方:

So I have deployed a Google Cloud Function to some place like this:

https://us-central1-my-project.cloudfunctions.net/my-function

我可以像这样成功渲染动态网页:

I can successfully render a dynamic webpage like this:

https://us-central1-my-project.cloudfunctions.net/my-function?slug=foo

现在,我想将其放在常规网址之后,使其工作如下:

Now, I would like to put this behind a regular URL so it works like this:

https://my-domain.com/some-directory/foo

我希望它是 https 而不是http.并且请注意,我在 foo 子句上方添加了 some-directory ,所以那里有一些重写逻辑.

I would like for it to be https instead of http. And notice that I added some-directory above the foo slug, so there is a little bit of rewriting logic there.

所以基本上从这里到这里:

So basically go from here to here:

https://us-central1-my-project.cloudfunctions.net/my-function?slug=foo
https://my-domain.com/some-directory/foo

问题是如何执行此操作.想知道您能否带领我逐步了解如何做到这一点,我认为这也将对将来的Google员工有所帮助.

The question is how to do this. Wondering if you could walk me through how to do it which I think would also help future googlers.

当我搜索用于Google云功能的自定义域"时,我会得到

When I search "custom domain for google cloud function" I get this which is for "endpoints" or "openapi" or I don't know, but it doesn't quite seem related. However, I went ahead anyways and changed my DNS nameservers to match what they said:

A     198.51.100.0
A     198.51.100.2
A     198.51.100.4
A     198.51.100.6
AAAA  2001:db8:ffff:32::15
AAAA  2001:db8:ffff:34::15
AAAA  2001:db8:ffff:36::15
AAAA  2001:db8:ffff:38::15

但是我不知道下一步该怎么做.不幸的是,与AWS相比,Google Cloud的文档简直一无是处.

But I am lost as to what to do next. The documentation for Google Cloud is nothing compared to AWS which is unfortunate.

与我所发现的非常接近远,但还远远不能使它正常工作.也许更接近我想要的./p>

This is as close to what I've found so far, but it's still not even close to getting it working. Maybe this is closer to what I want.

推荐答案

使用在GCP项目中部署的Google Cloud Functions,这是不可能的.

This is not possible using Google Cloud Functions deployed in a GCP project.

当前,将自定义域映射到HTTP/S触发功能的唯一方法是使用 Firebase托管.

Currently, the only way to map a custom domain to your HTTP/S triggered functions is by using Firebase Functions and Firebase Hosting.

创建自定义域后,您可以将域配置为处理触发的HTTPS/S功能.

After creating the custom domain, you can configure the domain to handle HTTPS/S triggered functions.

这篇关于如何为Google Cloud Functions配置自定义域以呈现HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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