Log in |
Apache As A Front End To ZServerProblemIn my situation, Apache is currently used to serve all our content. Each Apache server typically supports a few virtual hosts. I'd like to use ZServer to serve some content to take advantage of Zope's features. However, some of our content, eg. third-party documentation, generated JavaDoc, is not really suitable to be added into the ZODB. In addition, we are likely to continue to use Apache as we have found it to be very good. Hence, I needed a way of configuring Apache and Zope to permit me to use Apache as a front end to manage virtual hosts, serve some content and redirect the remaining URLs to ZServer.SolutionThe How-Tos listed below were very useful in getting me started. I encountered problems as I tried each one, which pushed me into trying the others. In the end, the problems turned out to be browser related (I think), so I suspect the other solutions work just as well as mine. However, having to try out several solutions helped me reach a very neat solution (in my opinion).ZServer ConfigurationI used the standard startup script for Zope. This means a ZServer running on port 8080 of my host. I created a Folder calledXYZ in the
root folder to represent the (virtual) host xyz.mydomain.com .
SiteAccess ConfigurationI added aSiteRoot object into the XYZ folder.
It was configured with a blank title, a base equal to
http://xyz.mydomain.com and a path equal to / .
Apache ConfigurationMy solution uses Apache's re-write rules, which means Apache must be built withmod_rewrite . The key re-write rule uses the proxy option,
which means Apache must also be built with mod_proxy .
Below are relevant commands from Apache's httpd.conf file.
NameVirtualHost 123.456.78.9 <VirtualHost 123.456.78.9> ServerName xyz.mydomain.com DocumentRoot /path/to/htdocs <IfModule mod_rewrite.c> RewriteEngine On RewriteLog "/path/to/apache/logs/rewrite_log" RewriteLogLevel 0 RewriteRule ^/local/ - [L] RewriteRule ^/(.*) http://xyz.mydomain.com:8080/XYZ/$1 [P] <IfModule> <VirtualHost>The Apache rewrite rules work as follows. The RewriteEngine
command turns the rewrite engine on.
The
RewriteLog
command specifies where to log rewrite actions.
The
RewriteLogLevel
determine how much is logged. A level of 0 is useful for production. Levels
from 1-9 give you useful debugging output.
The
RewriteRule
commands specify what Apache does with incoming requests to
xyz.mydomain.com .
The rules are processed from first to last, hence order is important.
The first rule specifies that all requests beginning with /local/
are served by Apache. (This is achieved by the - implying no
action, and the [L] implying that rule processing is to stop.
The second rule, specifies that all remaining requests are forwarded to
http://xyz.mydomain.com:8080/XYZ/ using Apache's proxy
module (the [P] ).
Tricks and TrapsI found the order of things important in my solution. You should configure ZServer, install SiteAccess, start ZServer, create any Folders, add SiteRoot objects and then configure and start Apache. I found that if I reconfigured Apache and tried to manage the new virtual host before I added the SiteRoot object, I was asked to login twice. The first login appeared to be toxyz.mydomain.com .
The second appeared to be to
xyz.mydomain.com:8080 .
Once the SiteRoot object was added this problem went away.
The other problem I encountered was a kind of infinite loop. If I started
with a vanilla Apache configuration, configured the Zope side of things
(which required logging in) and then reconfigured Apache I got into trouble.
When I tried to manage the virtual host again within Zope the browser kept trying, over
and over, to go to the site. A check of the Apache server log revealed
repeated 401 errors. 401 is Authorisation Failure, suggesting the browser
thought it had access permission but ZServer did not. The only way around this
was to restart the browser. The broswer in question is Netscape 4.73 under NT.
EnvironmentThe above solution has been verified using the following software. However, I don't believe I used any version specific features.
Relevant How-TosUsing Apache with ZServer (NOT Zope.cgi)Serving ZOPE and other content from Apache ZOPE/Apache Virtual Host For a full list, search for Apache
using the main zope.org search facility.
|