通过全局https loadbalancer用无用的neg作为后端,将自定义域的定制域与Google Cloud函数指向Google Cloud函数

发布于 2025-01-26 16:46:10 字数 1165 浏览 6 评论 0原文

我有一个运行myFunctionName带有http触发URL的云函数:

对于Ex- https://us-central1-my-project.cloudfunctions.net/myfunctionname

我现在想将此云功能URL映射到

ex- https://my-domain.com/path

公共域URL的公共域URL中,以DNS设置为LoadBalancer。全局外部HTTPS LoadBalancer是由主机,路径规则&创建的后端服务

主机:my-domain.com,路径规则:/path,后端服务:无用的neg指向myFunctionName cloud cloud函数 P>

如果我点击了带有云函数http触发URL的API端点,API响应为200,它正在工作

get endpoint上的请求https://us-central1-my-project.cloudfunctions.net/myfunctionname/show/jobs

但是当我使用自定义域名登录API端点时URL:

get endpoint上的请求https://my-domain.com/path/show/jobs

API错误响应是404。无法获得/myfunctionNameshow/jobs

有人可以指出问题,为什么我的自定义域URL未重定向到云功能URL?实际上,我的期望是击中https://my-domain.com/path/show/jobs api端点应该等于https://us-central1-my-project.cloudfunctions https://us-central1-my-functions。 .net/myFunctionName/show/jobs api端点。

I had a running myfunctionname cloud function with HTTP trigger URL:

For Ex- https://us-central1-my-project.cloudfunctions.net/myfunctionname

Now I want to map this cloud function URL to public domain URL

For Ex- https://my-domain.com/path

Public domain URL is setup in DNS to point to loadbalancer. Global external https loadbalancer is created with host, path rules & backend service

Host: my-domain.com , Path Rule: /path , Backend Service: Serverless NEG pointing to myfunctionname cloud function

Now if I hit the API endpoint with the Cloud Function Http trigger URL, API response is 200 OK, it's working

GET Request on endpoint https://us-central1-my-project.cloudfunctions.net/myfunctionname/show/jobs

But when I hit the API endpoint with the custom domain URL:

GET Request on endpoint https://my-domain.com/path/show/jobs

API error response is 404 Not Found. Cannot GET /myfunctionnameshow/jobs

Can someone please point out the issue why my custom domain URL is not redirected to cloud function URL? Actually my expectation is hitting https://my-domain.com/path/show/jobs API endpoint should be equivalent to hitting https://us-central1-my-project.cloudfunctions.net/myfunctionname/show/jobs API endpoint.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文