Appengine modules dispatch.xml routing with custom

2019-04-17 12:35发布

问题:

I have someone got appengine modules working. i have two modules, app and auth. i have a custom domain say domain.com, i want to route app.domain.com to app module, and auth.domain.com to auth modules, following is my dispatch.xml file,

<dispatch>
    <!-- Default module serves simple hostname request. -->
    <url>*/favicon.ico</url>
    <module>default</module>
</dispatch>

<dispatch>
    <!-- Auth Service to auth module -->
    <url>auth./*</url>
    <module>auth</module>
</dispatch>

<dispatch>
    <!-- Default module serves simple hostname request. -->
    <url>*/favicon.ico</url>
    <module>default</module>
</dispatch>

since app module is default app.domain.com is successfully routed, but i couldn't able to route auth.domain.com to auth module, its always pointing to default module,

how can i route custom domain to server specific module?

Thanks

回答1:

Use full hostname:

<dispatch>
  <-- * in front of hostname (*auth) is optional -->
  <-- it allows for subdomain (version) mapping  -->
  <url>*auth.hostname.com/*</url>  
  <module>auth</module>
</dispatch>

You should also consider configuring the subdomain wildcard mapping: then GAE will allow you to map to particular module versions, e.g.

auth.hostname.com -> auth module, default version
v1.auth.hostname.com -> auth module, version v1

This is useful for using SSL during development, when you want to directly address particular version of a module.