问题
Here is what I'd like to achieve
http://foo.somedomain.com gets handled by http://myapp.appspot.com/foo (google appengine app myapp) and the underlying url is masked.
Note the following:
- somedomain.com is a third party domain that would like to add foo.somedomain.com
- mydomain.com would be CNAME'd to myapp.appspot.com
- mydomain.com/foo would point to myapp.appspot.com/foo
other scenarios
- can foo.mydomain.com be made to point to myapp.appsot.com/foo
- can foo.somedomain.com point directly to myapp.appspot.com/foo
Added: myapp.appspot.com is developed using django w/ app-engine-patch
回答1:
You can't do this in the way described. In order to do this, you need to:
- CNAME foo.somedomain.com to ghs.google.com (not to myapp.appspot.com)
- Set up Google Apps for your Domain on somedomain.com, if it's not already
- Add the app 'myapp' to foo.somedomain.com through the Apps control panel
Once that's done, your app can check self.request.host to determine which hostname was sent, and route requests appropriately.
回答2:
You can parse the sub-domain from the Host
header, then call the webapp.RequestHandler
appropriate for the path /[sub-domain]
, assuming *.yourdomain.com
is directed to the Google App Engine application.
Have a look at webapp.WSGIApplication
and see if there's a way to get the mapped webapp.RequestHandler
for a path. Alternatively, you might be able to modify the request object to change the requested path (this I'm not sure about, however.)
回答3:
This question was asked in one of the 2009 Google I/O app engine talks. Unfortunately the answer given was along the lines of not supported at this time but the possibilities of some workarounds may exist. 2009 Google I/O videos
来源:https://stackoverflow.com/questions/976127/how-do-i-get-foo-somedomain-com-get-handled-by-myapp-appspot-com-foo-on-appengin