3
votes

This page (https://cloud.google.com/appengine/docs/standard/nodejs/mapping-custom-domains) states:

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.

Also, this page (https://cloud.google.com/appengine/docs/standard/java/how-requests-are-routed) states:

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]


I have the following services for my App Engine project:

enter image description here

and following versions for this service:

enter image description here

"1" is the default version. "test1" is a test version.

Yet when I enter https://test1.mycustomdomain.com into a browser, it serves the default version, not the "test1" version.

If I enter https://test99.mycustomdomain.com into a browser, I see an error page because this version does not exist (as expected).

The URL, https://test1-dot-MY_PROJECT_ID.appspot.com/ works as expected (i.e. serves the "test1" version).

These are my configured domains:

enter image description here

How do I get App Engine to route a request to the correct version?

1

1 Answers

2
votes

Any domain directly mapped to your app will serve the default service. If test1.mycustomdomain.com is mapped as a custom domain, it will always serve 1 (default).

To serve named GAE versions with a custom domain, you'll need to map the domain with the wildcard (*.mycustomdomain.com) and remove the other mapped subdomains that are conflicting with your versions. An example of working mapped domains would be:

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

With that setup, test1.mycustomdomain.com should serve the correct version, test1.


Edit

Regarding wildcard mapping and HTTPS

The GCP documentation about wildcard mapping states that:

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

This can lead to believe that wildcard mapping doesn't support HTTPS. The documentation is referring to the managed certificates that GAE provides. App Engine does support SSL certificates for wildcards if you use your own SSL certificates:

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.