4

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?

Guillermo Cacheda
  • 2,162
  • 14
  • 23
Paul Grime
  • 14,970
  • 4
  • 36
  • 58

1 Answers1

2

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.

Guillermo Cacheda
  • 2,162
  • 14
  • 23
  • Do I have to remove *all* mapped subdomains, or just the 'conflicting' one? I.e. do I have to remove the "api", "test1" and "www" mappings just to get "test1" to work? Also, a wildcard mapping does not seem to allow HTTPS, which I require. – Paul Grime Oct 01 '18 at 16:02
  • 1
    @PaulGrime you will need to remove just the conflicting ones, I'll edit my answer to clarify that part. Regarding the HTTPS part, I'm guessing you say so because of the documentation stating that ["Wildcard mappings are not supported for managed SSL certificates."](https://cloud.google.com/appengine/docs/standard/nodejs/mapping-custom-domains#wildcard_mappings). This "managed certificates" reference the ones that Google provides to your custom domains in GAE. You can still use your own to protect wildcard domains. Will add this information to the edit. – Guillermo Cacheda Oct 02 '18 at 13:30