[Zope-dev] SiteAccess: virtual host monster and setServerURL issue

Joseph Wayne Norton norton@arseed.co.jp
Tue, 10 Apr 2001 18:58:39 +0900


--Multipart_Tue_Apr_10_18:58:39_2001-1
Content-Type: text/plain; charset=US-ASCII


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://localhost:1080/VirtualHostBase/http/%{HTTP_HOST}/vtfs/%{SERVER_NAME}/VirtualHostRoot/$1 [P,L]

 * HTTP_HOST varies depending on how the client reaches the apache
   server.
 
 * 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
connections.

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
        else:
            host = hostname + ':' + port
        server_url = other['SERVER_URL'] = '%s://%s' % (protocol, host)
        self._resetURLS()
        return server_url



--Multipart_Tue_Apr_10_18:58:39_2001-1
Content-Type: text/plain; charset=US-ASCII

-- 

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

--Multipart_Tue_Apr_10_18:58:39_2001-1--