Evan and Zope Dev -

I'm using the virtual host monster with apache proxy/rewrite
mechanism.  I faced a little bit of trouble dealing with zope's
setServerURL method.

I'm using a configuration such as this on the apache side:

RewriteRule     ^/(.*)$ \

 * HTTP_HOST varies depending on how the client reaches the apache
 * SERVER_NAME (or really the name of the virtual host) is a constant
   defined in the apache virtual host.

The correct virtual URL is not setup properly because the setServerURL
method is always picking up the port #1080 (via oldhost,oldport) from
the mod_proxy/mod_rewrite request environment even if HTTP_HOST does
not contain a port number.  I patched this issue by simply commenting
out the lines below.

I would like to keep using the HTTP_HOST variable mechanism, because
the absolute_url() generated doesn't directly depend on the proper dns
settings of the web client.  For example, this allows apache to serve
the content properly even if ssh is being used to forward http/https

Any recommendations??

- joe n.

    def setServerURL(self, protocol=None, hostname=None, port=None):
        """ Set the parts of generated URLs. """
        other = self.other
        server_url = other.get('SERVER_URL', '')
        if protocol is None and hostname is None and port is None:
            return server_url
        oldprotocol, oldhost = splittype(server_url)
        oldhostname, oldport = splitport(oldhost[2:])
        if protocol is None: protocol = oldprotocol
        if hostname is None: hostname = oldhostname
        #if port is None: port = oldport
        #if (port is None or default_port[protocol] == port):
        if (port is None):
            host = hostname
            host = hostname + ':' + port
        server_url = other['SERVER_URL'] = '%s://%s' % (protocol, host)
        return server_url


Joseph Norton
     C.T.O. (Chief Technology Officer)
              Tel:03-5431-5240 (Fax:5241)
Visit us! http://www.arseed.co.jp/garden/

Reply via email to