Nicky Feller
Nicky Feller

Reputation: 3899

GCP Point Custom Domain to Specific App Engine Service

I currently have an Google App Engine Flexible project with four services. And when I map my custom domain to my project using the documentation https://cloud.google.com/appengine/docs/standard/python/mapping-custom-domains, it automatically points to the default service which is not the frontend application. How do I map it to a different service.

Upvotes: 8

Views: 3284

Answers (2)

Marco Weber
Marco Weber

Reputation: 839

The answer from @dan isn't up to date anymore:

The naming of the dispatch.yaml file changed from 'module' to 'service', like this:

dispatch:
   - url: "sub1.yourdomain.com/*"
     service: web-app

You deploy the stand-alone-file via this command (it hasn't to be in a project folder):

gcloud app deploy dispatch.yaml

Reference: https://cloud.google.com/appengine/docs/standard/python/config/dispatchref

Upvotes: 13

Dan Cornilescu
Dan Cornilescu

Reputation: 39824

You cannot map a certain (sub)domain to a certain service in the app-level custom domain mapping, mapping is done only at the app level (as a whole).

To direct a certain (sub)domain to a certain service inside your app you'll need to use a dispatch file, for example:

dispatch:
  - url: "example.com/*"
    module: <frontend-service-name>

Side note: you may want to revisit the decision of handling the frontend in a non-default service: the frontend is IMHO best suited to handle any garbage request coming in (which would typically not match any routing rule and would thus be directed towards the default service). If your default service does something more sensitive than the frontend it might not like that spam coming in.

Upvotes: 7

Related Questions