[Zope] Vhosting

Adam Getchell AdamG@hrrm.ucdavis.edu
Thu, 22 Aug 2002 17:27:42 -0700


Hello all,

I've read and re-read http://www.zope.org/Members/4am/SiteAccess2/vhosting a
number of times.

I have a webserver that needs to host a bunch of different sites,
site1.ucdavis.edu, site2.ucdavis.edu, etc.

I planned to use name based redirection, so I have c-names to the IP address
of the server, i.e. site1.ucdavis.edu --> IP, site2.ucdavis.edu --> IP, etc.

I installed on OpenBSD, so Zope runs as an instance in /home/zoperoot under
port 8080, and Squid sits in front of it and redirects from 80 to port 8080.
This part is working fine.

Under my main zope site, I created two folders, site1 and site2. I then
created, in each folder, an empty SiteRoot. That is, Title, Base, and Path
are all blank. At least, that's how I interpreted the directions above.

I then created a DTML method called host_redirector, with the following
content:

Extract the part of HTTP_HOST we care about, and declare our rewrite
dictionary.
<dtml-let hostname="_.string.upper(_.string.split(HTTP_HOST, '.')[0])"
          sitemap="{'SITE1': 'site1',
                    'SITE2': 'site2'}">
    Do we have a match?
    <dtml-if expr="sitemap.has_key(hostname)">
Set the logical root: <dtml-call "REQUEST.set('SiteRootPATH', '/')">
Add physical root: <dtml-call
"REQUEST['TraversalRequestNameStack'].append(sitemap[hostname])">
    </dtml-if>
</dtml-let>

Since I only care about the first part of the name, I rewrote the script
from the example. It may be incorrect! I tried the equivalent at a python
interpreter, but I may certainly have goofed up.

In the root folder, I Set an Access rule to host_redirector.

I changed the index pages in each of Site1 and Site2 to differentiate them.
However, going to site1.ucdavis.edu gives the top level index_html, while
going to site1.ucdavis.edu/site1 gives index_html in the Site1 folder, so
clearly I did something wrong.

Any pointers?

***************************	
*	Adam Getchell
AdamG@hrrm.ucdavis.edu
*	System Architect/Programmer			(530) 752-1584
*	Human Resources Information Systems
http://www.hr.ucdavis.edu/
***************************	
"Invincibility is in oneself, vulnerability in the opponent." -- Sun Tzu