[Zope] Apache + ZServer
tonyr@ep.newtimes.com
tonyr@ep.newtimes.com
Tue, 11 Jan 2000 14:10:45 -0700
There appears to be a very common, question swirling around the zope
mailing list, how to integrate Zope & Apache. I thought I would chime
in with my two cents.
The following solution addresses:
1- Serving mixed Zope and static files via Apache.
2- Reduce the amount of work Zope has to do for non dynamic content (ie
images)
3- Allow for serving from multiple Zope servers in a flexible manner.
4- All this within VirtualHost (I currently am trying SiteAccess)
Here exerts from from my httpd.conf file:
====================================================================
Listen 192.168.30.100:80
Listen 192.168.30.107:80
Listen 192.168.30.108:80
FastCgiExternalServer /home/httpd/htdocs/zope/1 -host
192.168.30.100:8889 -pass-header Authorization
FastCgiExternalServer /home/httpd/htdocs/zope/2 -host
192.168.30.103:8889 -pass-header Authorization
<Directory /home/httpd/htdocs/zope/>
SetHandler fastcgi-script
</Directory>
NameVirtualHost 192.168.30.100
NameVirtualHost 192.168.30.107
NameVirtualHost 192.168.30.108
<VirtualHost 192.168.30.100>
ServerName www.vhostdomain.com
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
DocumentRoot "/home/httpd/htdocs"
RewriteEngine on
RewriteLog /var/log/httpd/rewrite_log
RewriteLogLevel 0
RewriteMap servers rnd:/etc/httpd/conf/map.txt
RewriteRule /(.*gif)$ http://192.168.31.150:8080/vhost/$1 [P,L]
RewriteRule ^/$ - [S=1]
RewriteCond /home/httpd/htdocs%{SCRIPT_FILENAME} -s [OR]
RewriteCond /home/httpd/htdocs%{SCRIPT_FILENAME} -d [OR]
RewriteCond %{SCRIPT_FILENAME} ^/icons.*
RewriteRule ^/(.*) - [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^/(.*)
/home/httpd/htdocs/zope/${servers:zope|1}/$1
[e=HTTP_CGI_AUTHORIZATION:%1,e=SITE:vhost,L]
ProxyRequest on
CacheRoot "/home/proxy/vhost"
CacheSize 50000
CacheDefaultExpire 12
CacheGcInterval 2
</VirtualHost>
====================================================================
Here the "index" page ("/") is served via Zope, but that could easily be
changed by removing the line RewriteRule ^/$ - [S=1]. Then Apache would
serve the "/index.html" file if it exists.
This solution will serve any file physically accessible in document root
via the plain old Apache mechanisms. When a file is not found it will
use Zope to serve the content.
Also employed here is the proxy caching mechanism of mod_proxy to serve
.gif files so that Zope is not having to serve these files for each
request.
One more feature here is a random rewrite map to pull zope content from
multiple zope servers. This is just the beginning phases of a broader
load balancing solution that would allow for dynamic selection from a
pool of active Zope servers, with possible classing Zope servers as
having changeable ZODB or R/O ZODB. Then mapping which URLs should be
served via which server(s). This rewrite map file can be altered while
Apache is running and the changes dynamically reloaded via the
mod_rewrite engine. This would allow an external monitoring process to
alter the map file based on Zope server loads and/or availability.
This is not the entire picture but I think it's enought to put out here
and get some feedback. I will write this up as yet another Apache Zope
HowTo if you think is is a worthy approach.
Does anyone have extensive experience using the SiteAccess Product with
ZDiscussions and/or Catalog Aware ZClasses? This is one sticking point
we are having with serving VirtualHost, via one Zope ZODB. (Actually
are there any other alternatives to SiteAccess that people are using?)
Thanks.
--
-------------------------------
tonyr@ep.newtimes.com
Director of Web Technology
Newtimes Inc.
-------------------------------