RE: [Zope] VirtualHostMonster w/ ZServer
If I understand your example properly, when someone types in www.foo.com, the Access Rule I have in the root directory uses the Python script to send requests to the /vhosts/foo directory. I tried that and got it working as a test one level up in a directory I called /root because I didn't want to risk locking myself out, i.e. /root/vhosts/foo. Now, the second part of the equation is to put the VHM in the directory you want to be the root so all objects in that directory return logical path of / instead of their true physical path. In my example above, putting a VHM in the /root/vhosts/foo directory changes the paths of the objects in /root/vhosts/foo to just /root when using www.foo.com/root as the URL. I got this working as well. The one question I have is regarding the naming convention of the VHM. It doesn't seem to matter what the name/ID of the VHM is as long as "VirtualHostRoot" is used in the requesting URL. Likewise, you can change "VirtualHostRoot" in the requesting URL to something else like "testVHM" and as long as the VHM is called "testVHM", it works. Is there a preferred naming convention? Walter
What's the "best" way to set up a few virtual hosts using only ZServer? For example, to make www.mysite.com/vhosts/foo and www.mysite.com/vhosts/bar appear as www.foo.com and www.bar.com respectively. Do I need a SiteRite product or can this work with just a VirtualHostMonster?
Neither SiteRoots nor VirtualHostMonsters can do the job by themselves. They both need somebody doing the first half of the virtual host mapping -- sending requests for www.foo.com to /vhosts/foo. Apache can do this, but if you want a bare ZServer, you'll need to use an Access Rule. Setting the following Script as root Access Rule should do it, in conjunction with a VHM: ## Script (Python) "vhost_access" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath= ##parameters=self, req, resp ##title=Virtual Host Access Rule ## host = req['HTTP_HOST'] stack = req['TraversalRequestNameStack'] # Put path elements on the stack in reverse order. if host == 'www.foo.com': stack.extend(['VirtualHostRoot', 'foo', 'vhosts']) elif host == 'www.bar.com': stack.extend(['VirtualHostRoot', 'bar', 'vhosts']) Cheers, Evan @ digicool & 4-am
From: "Walter Miller" <wmiller@macromedia.com>
If I understand your example properly, when someone types in www.foo.com, the Access Rule I have in the root directory uses the Python script to send requests to the /vhosts/foo directory.
Exactly.
Now, the second part of the equation is to put the VHM in the directory you want to be the root
In the Zope root, actually. The "VirtualHostRoot" path element selects the virtual root.
so all objects in that directory return logical path of / instead of their true physical path.
The one question I have is regarding the naming convention of the VHM. It doesn't seem to matter what the name/ID of the VHM is as long as "VirtualHostRoot" is used in the requesting URL. Likewise, you can change "VirtualHostRoot" in the requesting URL to something else like "testVHM" and as long as the VHM is called "testVHM", it works.
True, and true.
Is there a preferred naming convention?
Only if you prefer one. Using "VirtualHostRoot" has the minor benefit that if you ever rename the VHM, you don't have to change your paths. Cheers, Evan @ digicool & 4-am
participants (2)
-
Evan Simpson -
Walter Miller