Log in |
Virtual Hosts via Apache (but nearly all content in Zope)This is definitely a FAQ on the Zope mailing list, so here's how I've got it running. Software Versions
Software SettingsApache(Note that there should really be no spaces between the square brackets and the L or P in the rewrite rules. The structured text rules at zope.org kept interpreting them as anchors for footnotes; if anyone knows how to put text inside a set of square brackets without STX thinking it's a footnote, please let me know. The <IfModule> directives are optional, and keep your Apache server from aborting on startup if you forgot to configure support for mod_rewrite.) httpd.conf:
LoadModule proxy_module /usr/lib/apache/1.3/libproxy.so
LoadModule rewrite_module /usr/lib/apache/1.3/mod_rewrite.so
NameVirtualHost my.real.host.name
<VirtualHost my.virtual.host.name>
ServerName my.virtual.host.name
DocumentRoot /var/www
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteLog "/var/log/apache/rewrite_log"
RewriteLogLevel 1
RewriteRule ^/local/ - [ L ]
RewriteRule ^/icons/ - [ L ]
RewriteRule ^/~(.*) - [ L ]
RewriteRule ^/cgi-bin/ - [ L ]
RewriteRule ^/(.*) \
http://my.real.host.name:9673/VirtualHostBase/http/my.virtual.host.name:80/MyTopLevelContentFolder/VirtualHostRoot/$1 [ P ]
</IfModule>
</VirtualHost>
Replace my.virtual.host.name with whatever canonical hostname you want to publish under. In my case, that would be www.cae.tntech.edu. Replace my.real.host.name in the NameVirtualHost line with the "real" hostnames of the Zope server assigned to it by your network administrator. In my case, that would be ch208h.cae.tntech.edu. In the RewriteRule line, replace my.real.host.name with either the "real" hostname you used in the NameVirtualHost line, or with localhost. Localhost would be better from a security standpoint, if and only if you took the time to configure Zope to only listen on the loopback interface. That would at least protect you from any future remote exploits against ZServer itself, as ZServer would only talk to Apache. Replace MyTopLevelContentFolder with the name of the folder whose contents you want to publish as my.virtual.host.name -- in my case, www.cae.tntech.edu is held in a folder called "www.cae.tntech.edu". One nice thing about these rewrite rules is that it allows me to have >99% of my content in Zope, but if I need Apache to serve particular static content, third-party CGIs, or users' personal web space, I can. Static content goes in the /local/ directory, CGIs are available because of the /cgi-bin/ rule, and the ~ rule takes care of users' public_html directories. The /icons/ rule is to make sure that if Apache has to render a directory listing (when there's no index.html in the directory), it can find the necessary icons for that view. Zope ConfigurationVery little, actually. I have one VirtualHostMonster object sitting in the root of my Zope tree, and the tree that is published as www.cae.tntech.edu is in a top-level www.cae.tntech.edu folder. ProofApache-published content from user directory PHP content in non-Zope areas works, too - no extra rewrite rules required Final Notes Jens Vagelpohl suggested that you all set your
RewriteLogLevel back to zero once you've
verified that your rewrite rules are working
properly. Stefan Holek noticed that I could
remove the Adrian Brown asked about Tomcat or JServ running alongside Zope; that's no problem, either. With the following packages from Debian's woody release:
I was able to get jserv working after adding one RewriteRule:
RewriteRule ^/servlets/ - [ L ]
and reloading the Apache process. Evidence here and here Frank Sonnemans had suggestions for clarifying the explanation of the Apache configuration that I've now added. Hopefully it's clearer now. Finally, make sure you can resolve names properly. That means either a working DNS, or a proper hosts file. If you can't ping or nslookup the various hostnames you used in your config, you will have problems. ReferencesDocumentation for mod_rewrite and mod_proxy, numerous posts on the Zope mailing list (no, I certainly didn't come up with all these RewriteRules and such by myself -- if you had a public howto similar to this beforehand, let me know so I can properly reference you). |