[Zope] VirtualHostMonster w/ ZServer
Evan Simpson
evan@4-am.com
Tue, 6 Feb 2001 21:45:35 -0500
From: "Walter Miller" <wmiller@macromedia.com>
> 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