SiteAccess: virtual host monster and setServerURL issue
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 -- ___________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/
From: "Joseph Wayne Norton" <norton@arseed.co.jp>
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.
This is deliberate. Omitting the port number means "leave it alone". If you want port 80 (the http default), you need to specify it. Generated URLs will not have ":80" in them, since it *is* the default port. Cheers, Evan @ digicool & 4-am
Evan - I agree with your statement, but the system is behaving differently. The generated URLs should not have :80 in them and they do not ... rather they have :1080 included in the generated URLs although I have specifed something as follows: mod_rewrite result: proxy:http://localhost:1080/VirtualHostBase/http/www.foo.com/vtfs/www.foo.com/vdmn... [OK] and zope/vhm is generating URLs of the form: http://www.foo.com:1080/ I believe the setServerURL method is using the port number from the environment setup from the mod_proxy/mod_rewrite request. I'm currently using 1080 for zope (z2.py -w 1080). - j p.s. One more related question .... have you tried using mod_proxy/mod_rewrite with zope's webdav source port (-W) and virtual host monster? At Tue, 10 Apr 2001 10:57:15 -0400, Evan Simpson wrote:
From: "Joseph Wayne Norton" <norton@arseed.co.jp>
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.
This is deliberate. Omitting the port number means "leave it alone". If you want port 80 (the http default), you need to specify it. Generated URLs will not have ":80" in them, since it *is* the default port.
Cheers,
Evan @ digicool & 4-am
From: "Joseph Wayne Norton" <norton@arseed.co.jp>
The generated URLs should not have :80 in them and they do not ... rather they have :1080 included in the generated URLs although I have specifed something as follows:
mod_rewrite result:
proxy:http://localhost:1080/VirtualHostBase/http/www.foo.com/vtfs/www.foo.co m/vdmn/prd/vstg/VirtualHostRoot/
[OK]
Exactly. You haven't specified the port. You need this:
proxy:http://localhost:1080/VirtualHostBase/http/www.foo.com:80/vtfs/www.foo .com/vdmn/prd/vstg/VirtualHostRoot/
p.s. One more related question .... have you tried using mod_proxy/mod_rewrite with zope's webdav source port (-W) and virtual host monster?
I haven't tried it, but I have no reason to expect that it wouldn't work properly. Cheers, Evan @ digicool @ 4-am
participants (2)
-
Evan Simpson -
Joseph Wayne Norton