1
votes

I'm trying to setup our Google App Engine to have 4 services hosted under a custom domain, one for the naked domain and three subdomains, such that:

site.com -> Service: default
app.site.com -> Service: app
api.site.com -> Service: api
admin.site.com -> Service: admin

According to the documentation How Requests are Routed and Mapping Custom Domains, we should simply be able to rely on Google App Engines own URL pattern SERVICE_ID.CUSTOM_DOMAIN for the subdomains. We do not want to deal with a dispatch.yaml file, since it shouldn't be necessary and it'll complicate our CI/CD.

We've configured the custom domain A, AAAA and CNAME records in the Google Cloud console and mirrored the DNS config in our domain registrar.

The site.com naked domain correctly shows the default service, but the issue is that, so does all the other subdomains. They all just show the default service instead of the services they're supposed to. The services run just fine when using Google's appspot.com url, but for the custom domain, they all just point to the default service.

Someone asked a similar question here a few of months ago, but in our case we've already configured the CNAME entries for each of the specific services.

What am I missing here?

1

1 Answers

1
votes

The answer you mention is not correct at all. Actually, the answer suggest to add *.domain.com and service.domain.com to DNS.

The issue with this answer is that is kind of obvious that those entries should be added to the DNS for the correct name resolution but this is only the half of the story.

After some testing I've found that the docs are not clear at all of the steps needed to make this approach working.

In your DNS it is not necessary to add *.domain.com, actually you can add the only needed subdomains in the DNS for your app like in your case:

app.site.com  3599    IN      CNAME   ghs.googlehosted.com.
api.site.com  3599    IN      CNAME   ghs.googlehosted.com.
admin.site.com  3599    IN      CNAME   ghs.googlehosted.com.
site.com  3599    IN      A   [App Engine IPv4 IPs]
site.com  3599    IN      AAAA   [App Engine IPv6 IPs]

Now the trick to make this work is to add in App Engine the *.domain.com mapping. After doing this, the approach you mention should work.