[Zope] SiteAccess-Apache: passing HOST header

Martijn Pieters mj@digicool.com
Wed, 9 Aug 2000 14:18:29 +0200


On Wed, Aug 09, 2000 at 12:25:32PM +0200, Dr. Dieter Maurer wrote:
> Does anybody know how to convince Apache to pass
> the information from the HTTP HOST header down to ZServer.
> 
> This would be very useful for SiteAccess Access Rules.

HTTP_HOST _is_ passed on to ZServer. I built a generic ProxyPassCleanup
external method for use as a SiteAcces 2 Access Rule that relies on it:

import string

def cleanup(self):
    REQUEST = getattr(self, 'REQUEST', None)
    if not REQUEST: return 'No REQUEST found'
    if not REQUEST.has_key('HTTP_HOST'): return 'No Host found'

    parts = string.split(REQUEST.HTTP_HOST, ':')
    host = parts[0]
    port = (len(parts) > 1 and parts[1]) or 80 # Assume default http port

    REQUEST.setServerURL(hostname=host, port=port)
    return 'Server URL changed to %s:%s' % (host, port)

Just run it as an external method before you assign it as the Access Rule and
it will give you a diagnostic message.

-- 
Martijn Pieters
| Software Engineer            mailto:mj@digicool.com
| Digital Creations          http://www.digicool.com/
| Creators of Zope               http://www.zope.org/
| ZopeStudio: http://www.zope.org/Products/ZopeStudio
-----------------------------------------------------