google-app-engine - 将自定义子域映射到 App Engine 上的特定版本

标签 google-app-engine custom-domain

此页面 ( https://cloud.google.com/appengine/docs/standard/nodejs/mapping-custom-domains ) 说明:

Using subdomains

If you set up a wildcard subdomain mapping for your custom domain, then your application serves requests for any matching subdomain.

  • If the user browses a domain that matches an application version name or service name, the application serves that version.
  • If the user browses a domain that matches a service name, the application serves that service.


此外,此页面 ( https://cloud.google.com/appengine/docs/standard/java/how-requests-are-routed ) 指出:

Sends a request to an available instance of a specific version in the default service:

https://[VERSION_ID]-dot-[MY_PROJECT_ID].appspot.com

http://[VERSION_ID].[MY_CUSTOM_DOMAIN]



我的 App Engine 项目有以下服务:

enter image description here

以及此服务的以下版本:

enter image description here
"1"是默认版本。 "test1"是测试版。

然而当我输入https://test1.mycustomdomain.com进入浏览器,它提供默认版本,而不是 "test1"版本。

如果我输入 https://test99.mycustomdomain.com进入浏览器,我看到一个错误页面,因为这个版本不存在(正如预期的那样)。

网址,https://test1-dot-MY_PROJECT_ID.appspot.com/按预期工作(即提供 "test1" 版本)。

这些是我配置的域:

enter image description here

如何让 App Engine 将请求路由到正确的版本?

最佳答案

任何直接映射到您的应用程序的域都将提供默认服务。如 test1.mycustomdomain.com映射为自定义域,它将始终提供 1 (默认)。

要使用自定义域提供命名的 GAE 版本,您需要使用通配符 ( *.mycustomdomain.com ) 映射域并删除与您的版本冲突的其他映射子域。工作映射域的一个例子是:

  • mycustomdomain.com
  • www.mycustomdomain.com
  • *.mycustomdomain.com

  • 使用该设置,test1.mycustomdomain.com应该提供正确的版本,test1 .

    编辑

    关于通配符映射和 HTTPS

    GCP documentation about wildcard mapping指出:

    Note: Wildcard mappings are not supported for managed SSL certificates.



    这可能会导致相信通配符映射不支持 HTTPS。该文档指的是 managed certificates that GAE provides . App Engine 确实 support SSL certificates for wildcards如果您使用自己的 SSL 证书:

    Some App Engine features use special subdomains. For example, an application can use subdomains to address application services, or to address different versions of your application. To use these with SSL, it makes sense to set up a SAN or wildcard certificate. Wildcard certificates only support one level of subdomain.

    关于google-app-engine - 将自定义子域映射到 App Engine 上的特定版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52593330/

    相关文章:

    java - 如何从应用程序引擎上的 BlobKey 获取 blob 文件名

    javascript - 删除 gh-pages 自定义域

    python - Google App Engine WebApp/Python 自定义 404 处理程序实现

    java - App Engine 的替代/兼容数据存储?

    security - 在 App Engine 上加密用户数据

    python - 如何从 App Engine 的 Python Dev_server 解码持久日志文件

    firebase - 将子域连接到 firebase

    ssl - 如何在 Google Kubernetes Engine 上设置可扩展自定义域和自动 SSL 的架构

    saas - 如何将自定义域设置为 SAAS?

    ruby-on-rails - Heroku 自定义域 (Namecheap) 不起作用