9
votes

Suppose I have a Google App Engine application which has several modules which have several versions. Can I map a custom domain name to a specific version of a specific module of the application?

For example:

http://www.example.com should be mapped to http://module1-dot-app1.appspot.com

2
already read that article, and it doesn't answer my question - Korneel
Wildcard domain mapping can at least partially solve the problem, in that it allows to map any subdomain to be served by the application. So this will support module1.example.com to work - as long as "module1" exists in the application. However, I did not find a solution yet on how to map a DIFFERENT subdomain name to a specific module (like www -> module1.example.com, api -> module2.example.com), as with wildcard mapping enabled, any non-existing subdomain name (in your appspot context) would be served by the DEFAULT module. - Thomas W.

2 Answers

12
votes

1.Mapping a module to custom domain

Let's suppose you are admin for domain example.com and you want to map subdomain www.example.com to module webmodule in your application myapp.appspot.com

www.example.com -> webmodule.myapp.appspot.com

What you can do is going to admin.google.com and in App Engine Apps section configure your application so that it is mapped on web address www.example.com. Of course follow the instruction for configuring your domain (you should add a CNAME entry in your DNS configuration with ALIAS www and HOST ghs.googlehosted.com).

Once you did this, web address www.example.com is linked to your application default module. For redirecting to webmodule you need to configure application internal routing with dispatch file, as reported here:

https://developers.google.com/appengine/docs/python/modules/routing

In your case what you need is something like this (this is from dispatch.yaml file for Python application):

dispatch:

    - url: "www.example.com/*"
      module: webmodule

2.Mapping a version to custom domain

Regarding versions, it seems you cannot map an url to a specific module version. What you can probably do is mapping an url including version to a specific module, but this is maybe little bit confusing.

1
votes

As thetonrifles already pointed out, you must use the dispatch.yaml file, which goes in your default module.

However, I also came across some issues when using secure domains/subdomains. If you've already uploaded your SSL cert for your custom domain, and you add custom subdomains after the fact, you need to go back to the SSL cert section and enable those subdomains you added, otherwise they'll just keep showing blank.