Part of nevow.vhost View Source View In Hierarchy
Implements interfaces: nevow.inevow.IResource
VHostMonster resource that helps to deploy a Nevow site behind a proxy.
The main problem when deploying behind a proxy is that the scheme, host name and port the user typed into their browser are lost because the proxying web server forwards the request to something like http://localhost:8080/.
A vhost resource consumes the next 2 segments of the URL to rewrite the scheme, host and port in the request object. It then "forwards" the request to the site's root resource.
To install the resource use something like:
>>> root = MyRootPage()
>>> root.putChild('vhost', VHostMonsterResource())
>>> site = NevowSite(root)
An appropriate Apache configuration using mod_proxy would be:
ProxyPass / http://localhost:8080/vhost/http/real.domainname.com/If you only want to proxy a part of the url tree, try:
ProxyPass /foo/bar http://localhost:8080/vhost/http/real.domainname.com/foo/bar
Note how the path is equal on both the public and the private server. Where as the /vhost/http/real.domainname.com part tells the private server the scheme, hostname, and possibly port, the /foo/bar is needed at the end to let the private know the path also.
This also means your private server should serve the real content at /foo/bar, and not at the root of the tree.
Warning: anyone who can access a VHostMonsterResource can fake the host name they are contacting. This can lead to cookie stealing or cross site scripting attacks. Never expose /vhost to the Internet.| Line # | Kind | Name | Docs |
|---|---|---|---|
| 183 | Method | locateChild | Locate another object which can be adapted to IResource |