GCP Point Custom Domain to Specific App Engine Ser

2019-06-25 14:18发布

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.

2条回答
啃猪蹄的小仙女
2楼-- · 2019-06-25 14:50

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

查看更多
神经病院院长
3楼-- · 2019-06-25 14:53

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.

查看更多
登录 后发表回答