External subdomain is not routed to service with the same name but to default service

1,079 views
Skip to first unread message

Fred Erik

unread,
Dec 4, 2016, 4:19:48 PM12/4/16
to Google App Engine
Hi,

I want to setup one subdomain console-sandbox.my-domain.store for my sandbox project and one subdomain console.my-domain.store for my production project. The web frontend service is called console-sandbox / console, thus matching the subdomains. My API service is the default service in both environments. However, both subdomains get routed to the default service, which is not the behaviour the documentation describes.

Any ideas?
Thanks!

Jordan (Cloud Platform Support)

unread,
Dec 6, 2016, 10:17:26 AM12/6/16
to Google App Engine
As noted in the same documentation you referenced, you are indeed able to route specific URLs to different App Engine services with the use of a Dispatch file

Firstly ensure that your sub-domains are configured as custom domains for your App Engine application (which it seems like they already are as per your description). Once the URLs are properly routing to your App Engine app, you can then create a dispatch file that lists the specific URLs you want to have routed to your different services (aka modules). 

Once you have your dispatch list of URLs and services, you can run the following command to upload the dispatch configuration to your project (in this example for Python we need a YAML file instead of the XML file used for Java):

gcloud app deploy dispatch.yaml

Fred Erik

unread,
Dec 7, 2016, 10:51:48 AM12/7/16
to Google App Engine
Thank you for the answer, I got it working setting up a dispatch.yaml file. Still I don't get why the default routing does not apply. It doesn't matter anymore for me but other users might run into it as well.

Jordan (Cloud Platform Support)

unread,
Dec 8, 2016, 11:04:43 AM12/8/16
to Google App Engine
Whenever you associate a new custom domain to your App Engine project, it will always route to your Default service and version. Even if you associate a subdomain to the project as you did, it will still route to the default as the CNAME and A records are all the same. 

The way to reach a different service or version without using a dispatch file would be to use the full Routing URL 'http://version.service.subdomain.customDomain.com'. In your case this would look like 'http://console.console-sandbox.my-domain.store' to have your subdomain 'console-sandbox.my-domain.store' route to the default version of your 'console' service. 

Alternatively, you can instead use a wildcard subdomain '*' to allow App Engine to perform the routing of the URL to your specific services and versions. 

Note: If you have an SSL cert for your custom domain and want to use HTTPS, the URL will use '-dot-' instead of actual '.', like so 'https://version-dot-service-dot-customDomain.com

Fred Erik

unread,
Dec 8, 2016, 11:18:00 AM12/8/16
to Google App Engine
Thank you for the extensive answer. Now I understand, what I got wrong. I referred to:

https://service-dot-app-id.appspot.com
http://service.my-custom-domain.com

and registered service.my-custom-domain.com to my AppEngine, but you only had to register my-custom-domain. With registering service.my-custom-domain.com the actual url becomes
service.service.my-custom-domain.com. Maybe that could be explained more clearly in the How Requests are Routed section. Anyway, thank you!

Jordan (Cloud Platform Support)

unread,
Dec 8, 2016, 1:14:03 PM12/8/16
to Google App Engine
Thank you for your feedback Fred. I have forwarded the recommended documentation clarification to our backend team. 

Note, there is no eta for the implementation of this document change.  

Bruno Branta Lopes

unread,
Feb 8, 2017, 10:27:11 AM2/8/17
to Google App Engine
I'm with similar problem here, and the given solution haven't worked for me.

This are the steps I have done:


2. Configured DNS domain (A and AAAA records) as guided in previous step.

3. Successfully tested and had app.mydomain.com routing to my default version and default service.

4. After that, I have tried all alternative configurations below:

version.service.app.mydomain.com
service.project-name.app.mydomain.com
version.service.project-name.app.mydomain.com

with all of these DNS configurations (each in a different subdomain test):

- CNAME to app.mydomain.com
- A and AAAA records, same as in app.mydomain.com

5. All these tests lead to the same error page from Google:


Google

404. That’s an error.

The requested URL / was not found on this server. That’s all we know.



Any ideas on solving this?

Karthikeyan N

unread,
Oct 4, 2017, 10:08:16 AM10/4/17
to Google App Engine
Hi,

In the note at the end of this post, you have specified that '-dot-' can be used with custom domain as well. I tried to use this but it doesn't seem to work with custom domains. I have a version "v1" in my service "service1". I am able to access this version using https://v1.service1.mydomain.com. However if I try to access using https://v1-dot-service1.mydomain.com, it gets redirected to the default service (not service1). Is there some configuration that I am missing?

Regards
Karthik
Reply all
Reply to author
Forward
0 new messages