5

I want to have 2 custom subdomains mapped to different modules of my AppEngine app, i.e.:

a.my-domain.com -> default module
b.my-domain.com -> module-b

My dispatch.yaml looks like this:

dispatch:
  - url: "a.my-domain.com/*"
    module: default

  - url: "b.my-domain.com/*"
    module: module-b

and I both subdomains added to this app AppEngine custom domains and CNAME setup correctly.

The problem is hitting both a.my-domain.com and b.my-domain.com resolves to default module.

I haven't tried to do top-level wildcard mapping, i.e. *.my-domain.com to this app since I already have other subdomains mapped to another app.

Is this setup even possible at all with AppEngine?

alphageek
  • 770
  • 4
  • 15

2 Answers2

3

I managed to get such setup working with Google Apps.

The confusion I guess came from calling x.my-domain.com subdomains (I had the same problem initially) - they're actually just hosts on the *.my-domain.com domain.

I have the *.my-domain.com (primary) naked domain handled by Google Apps, redirected to www.my-domain.com - in the Domains menu in the Admin Console.

I added my App Engine app ID to the App Engine apps menu in the Admin Console. Then clicking on my my app's entry in that menu I created a Web address/new URL for each of the hosts by adding just the a and b with the naked domain (not subdomain!) selected in the dropdown list. Now I see in the Web address list:

WARNING: Careful when entering info at the above step as so far I was unable to remove/correct URLs, I hit exactly the issue described here (and calling support yesterday didn't help so far in my case): App Engine (On Google Apps) Custom Domain can't remove

In the Security -> SSL for Custom Domains menu in the Admin Console I have the wildcard SSL certificate for my naked domain in one of the 5 SNI slots. I added the 2 URLs now visible in the dropdown box (and in the Unassigned URLs list below) to the SNI-only serving mode.

I had a bit of trouble with my dispatch file - wasn't uploaded properly by PyCharm since I switched to modules, had to upload it manually (using appcfg.py --oauth2 update_dispatch .) and only after I included my app name in it it became effective (visible in the old GAE Apps console https://appengine.google.com/ as a Main -> Dispatch menu, couldn't yet find an equivalent in the Developer Console):

application: myapp
dispatch:
  - url: "a.my-domain.com/*"
    module: default
  - url: "b.my-domain.com/*"
    module: module-b

Note: it may take a while until the DNS changes are propagated (BTW, I aquired my naked domain through Google when I signed up and thus they are able to drive the DNS ops directly, I didn't have to do anything myself) - in my cases the propagation times were in the 5-15 min range.

Note: it also took a few minutes from the moment I added the URLs to my SSL certificate serving list until the pages started working - during that interval I was getting security warnings (I have secure enforced for all entries in my modules' .yaml files).

I think that's about it.

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Thanks, I finally got this to work thanks to your answer! I had been trying like crazy to get this to work using a dispatch element "service", which according to the documentation [dispatch.yaml reference](https://cloud.google.com/appengine/docs/standard/python/config/dispatchref) was the way to do it: "_service -- Specifies the name of the service that will handle the requests that match the url pattern. Note that services were previously called modules._". By replacing "service" with "module" my dispatch.yaml works. – 0x5f3759df Jan 29 '18 at 08:42
1

In case you're using Google Apps to configure your domain, it doesn't seem to be possible:

Applications that use Google App Engine are not available for users at non primary domains[1].

From "Google App Engine" at https://support.google.com/a/answer/182081

It's also mentioned at https://cloud.google.com/appengine/docs/ssl:

Google Apps does not support "secondary" domains for your App Engine app, as explained here. You can still use secondary domains with other apps you offer through Google Apps, but your App Engine app can only be accessed with your account's primary domain or its aliases.

You should be able to configure your domains without Google Apps, but if you need SSL support, which requires using Google Apps, I think there's no proper solution.

kvdb
  • 725
  • 6
  • 18