问题
Let's say I have myapp.appspot.com
and two custom domains respectively called foo.com
and bar.com
. How do I configure Google App Engine (GAE) such that:
(www.)foo.com -> foo.myapp.appspot.com
(www.)bar.com -> bar.myapp.appspot.com
(www.)foo.com -> myapp.appspot.com (default version)
I'm reading https://developers.google.com/appengine/docs/domain but I still don't understand how to configure it. I get the impression that GAE only supports wildcard for one custom domain e.g. **.foo.com
.
回答1:
You can't really do that directly, as you associate your custom domain with an App ID rather than the App URL.
I guess you could map both foo.com and bar.com to your App ID, then in the default version of your App Engine parse the URL, and redirect accordingly, but it's not a great solution as you would be redirecting from your custom domain back to appspot.com domain.
回答2:
You can route using the dispatch file (dispatch.yaml
).
This blog post gave me the necessary info, and I imagine for the case of needing to map multiple domains to different modules would require a dispatch.yaml
something like this:
# Dispatch
# ========
---
dispatch:
- url: 'foo.com/*'
module: foo
- url: 'bar.com/*'
module: bar
Don't forget to add the custom domains as well as SSL certs in the App Engine console.
来源:https://stackoverflow.com/questions/11288424/multiple-custom-domains-to-specific-version-of-google-app-engine-app