我们的应用程序使用 store1.example.com 和 store2.example.com 等子域,其中每个子域代表由我们的客户创建的唯一的、可公开访问的店面。我们希望将所有 *.example.com 流量路由到 Godaddy 的特定 Cloud Run 服务。我们如何配置 Cloud Run 以接受来自 example.com 下任何子域的请求以及 SSL?或者,GCP 内是否有其他解决方案来处理此用例
如果您希望将来自多个子域(例如 store1.example.com、store2.example.com 等)的所有流量定向到单个 Cloud Run 服务,该过程非常简单。方法如下:
要设置以下架构,您可以按照此文档进行操作 https://cloud.google.com/load-balancing/docs/https/setting-up-https-serverless
设置云负载均衡器:
首先,在 Google Cloud 中创建一个 Cloud Load Balancer。负载均衡器将充当来自子域的所有传入流量的网关。
附加 Cloud Run 作为后端:
在负载均衡器配置中,选择 Cloud Run 作为后端服务。这意味着通过负载均衡器的所有流量都将转发到您的 Cloud Run 服务。
将您的域指向负载均衡器:
接下来,在您的域名提供商(如 GoDaddy)中,将所有子域(例如 store1.example.com、store2.example.com)指向负载均衡器的同一外部 IP 地址。
自动处理所有流量:
由于您有一个 Cloud Run 服务作为后端,因此来自任何子域(例如 store1.example.com、store2.example.com 等)的所有流量都将路由到同一后端服务,无需额外配置。
如果它对您有用或者您有任何其他疑问,请告诉我