repoze.zope2 was always meant to have a virtual hosting story separate than that of Zope 2's "Virtual Host Monster".. Tres and I struggled with this mightily in the early days of Repoze development, and I thought we had it licked. But alas, on Friday, I was in the #repoze IRC channel, talking with David Durham. He noticed that when he added lines to his Apache mod_wsgi Location configuration (as documented) like so, to enable virtual hosting:
SetEnv HTTP_X_VHM_HOST http://www.example.com SetEnv HTTP_X_VHM_ROOT /plone
Nothing happened. So I went and looked at the code, and lo and behold it was BRIDGE OUT! We just had never finished the virtual hosting portion of repoze.zope2. Yikes, quite embarrassing, as I thought it had already been done. I had been documenting code that just didn't exist!
So today I went in and added it to repoze.zope2, and wound up releasing new versions of both repoze.zope2 (0.3.3) and repoze.vhm (0.5). It took a while for me to get virtual hosting working (I have four pages of notes to prove it; it took that much just to document what VHM was doing), but now you can use those headers in your Apache (or whatever) config to "turn on" virtual hosting when using repoze.zope2 with the repoze.vhm "xheaders" middleware in your WSGI pipeline. When running under this configuration, you can also now delete the virtual host monster from your Zope when using repoze.vhm if you need virtual hosting.
That's not very interesting, of course. What is interesting (to me, anyway) are these things:
So before where you used to need to put in your Apache configuration something like:
<VirtualHost *:80> ServerName www.example.com RewriteEngine On RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/www.example.com:80/plone/VirtualHostRoot/$1 [L,P] </VirtualHost>
You can (if you run under repoze.zope2 and repoze.vhm, proxying through to a Paste server) now replace that with:
<VirtualHost *:80> ServerName www.example.com RewriteEngine On RewriteRule ^/(.*) http://127.0.0.1:8080/$1 [L,P] RequestHeader add X-Vhm-Host http://www.example.com RequestHeader add X-Vhm-Root /plone </VirtualHost>
Or if you're running repoze.zope2 directly under Apache:
<Location /> WSGIPassAuthorization On SetEnv HTTP_X_VHM_HOST http://www.example.com SetEnv HTTP_X_VHM_ROOT /plone </Location>
Damn, that felt good.