[Zope] Multiple Sites and Apache

Mike Renfro renfro@tntech.edu
Thu, 19 Jul 2001 08:43:57 -0500


On Wed, Jul 18, 2001 at 08:05:55PM -0500, Thomas T. Veldhouse wrote:

> Actually, I do have another domain that I host as a virtual domain.
> It is also in need of development.  I wish I could find some more
> "readable" documentation on the Virtual Host Monster though.  The
> current Zope hosted docs are confusing.  The book leaves it to the
> administrators guide and the Administrators guide is unfinished.

Tom, have you checked out my howto at
http://www.zope.org/Members/mwr/VHosts_With_Zope_Default ? It covers
Zope plus Apache static, PHP, Jserv, CGI, and UserDir content. Plus,
at least one member of the Digicool cabal liked it.

But more to the point with VHM docs, let's say I have a top-level
folder in my Zope tree named "CAE" that I want to contain all the
content for a particular virtual host, www.cae.tntech.edu.

The third paragraph of the VHM Zope-hosted docs says "If the URL path
of a request begins with "/VirtualHostBase/http/www.foo.com", for
instance, then URLs generated by Zope will start with
http://www.foo.com." Ok, the main Zope-generated URL you'd want to
worry about is the one in the <base href> tag in the header of each
page.

So thus far, we know that if we want any URLs to cleanly derive from
the www.cae.tntech.edu site, Zope will definitely have to see a
request that begins with /VirtualHostBase/http/www.cae.tntech.edu --
and since *that particular request* is not something you'd expect the
user to type in themselves, it'll have to come from an Apache rewrite
rule.

The last part of the third paragraph says we'll probably want to dump
the port number, so the actual request to Zope will be
/VirtualHostBase/http/www.cae.tntech.edu:80

Fourth paragraph translation -- anything that comes before the word
VirtualHostRoot in the request will be stripped from any generated
URLs. We don't want URLs of the form
http://www.cae.tntech.edu/CAE/foo, so we need to make sure that the
CAE entry comes before the word VirtualHostRoot in the request.

Now our idea of the request Zope sees is almost complete: Zope sees a
request of
/VirtualHostBase/http/www.cae.tntech.edu:80/CAE/VirtualHostRoot, and
will render it to the browser as http://www.cae.tntech.edu/.

>From here on out, it's all Apache RewriteRules. You want to make sure
that any requests to Apache for http://www.cae.tntech.edu/foo are sent
to Zope as
/VirtualHostBase/http/www.cae.tntech.edu:80/CAE/VirtualHostRoot/foo --
and that's the gist of sixth paragraph, which is really a far more
condensed version of what I just spent the last page or so explaining.

  For example, suppose you want to publish Folder "/foo" as
  http://www.foo.com/, where Zope is running on port 8080 behind Apache
  running on port 80. You place a Virtual Host Monster in the root Zope
  folder, and use Apache to rewrite "/(.*)" to
  http://localhost:8080/VirtualHostBase/http/www.foo.com:80/foo/VirtualHostRoot/$1

The actual RewriteRule for my example site would be:

  RewriteRule ^/(.*) http://my.real.host.name:9673/VirtualHostBase/http/www.cae.tntech.edu:80/CAE/VirtualHostRoot/$1 [P]

all on one line.

-- 
Mike Renfro  / R&D Engineer, Center for Manufacturing Research,
931 372-3601 / Tennessee Technological University -- renfro@tntech.edu