VirtualHostMonster and "unpack list of wrong size"
Hi all. After installing Zope 2.6final (which was rather a rather smooth transition from 2.5.1, congrats to all involved!) we found that our current setup exposed a very annoying behaviour. We have Apache doing the virtual host dance in front of Squid in accelerator mode to keep the system load low in front of Zope. Apache is intrumented with the usual Rewrite-Rule a la RewriteRule /(.*) http://localhost:1234/VirtualHostBase/http/%{HTTP_HOST}:80/cms_root/some_name/VirtualHostRoot/$1 [L,P] Now there seem to be cases (we tracked most of them to usage of wget as a user agent) where VirtualHostMonster tries to decode "www.hostname.tld:80:80". The error occurs when VHM tries to execute host, port = host.split(':') Granted the original request is invalid and should at least generate a warning I'd suggest replacing the cited line by hostparts = host.split(':') host = hostparts[0] port = hostparts[1] This is not a bugfix since the hostname/port combination is obviously invalid, but it does add reasonable behaviour along the lines of "be liberal in what you accept and be conservative in what you send", which was one of the first lines I memorized when I started learning about protocols. Jo. -- Internetmanufaktur Jo Meder ---------------------- Berlin, Germany http://www.meder.de/ ------------------- fon: ++49-30-417 17 63 33 Kollwitzstr. 75 ------------------------ fax: ++49-30-417 17 63 45 10435 Berlin --------------------------- mob: ++49-170- 2 98 89 97 Public GnuPG-Key ---------- http://www.meder.de/keys/jo-pubkey.txt
Jo Meder writes:
... Apache is intrumented with the usual Rewrite-Rule a la
RewriteRule /(.*) http://localhost:1234/VirtualHostBase/http/%{HTTP_HOST}:80/cms_root/some_name/VirtualHostRoot/$1 [L,P]
Now there seem to be cases (we tracked most of them to usage of wget as a user agent) where VirtualHostMonster tries to decode "www.hostname.tld:80:80". The error occurs when VHM tries to execute A well known problem:
Some HTTP clients include the port in the "HOST" HTTP header. Use an Apache "RewriteCond" to strip away the port if it is present: RewriteCond %{HTTP_HOST} ([^:]*)(:.*)? RewriteRule ..../http/%1:80/... Dieter
Am 23.10.2002, 20:23 Uhr schrub Dieter Maurer <dieter@handshake.de>:
Some HTTP clients include the port in the "HOST" HTTP header.
Use an Apache "RewriteCond" to strip away the port if it is present:
RewriteCond %{HTTP_HOST} ([^:]*)(:.*)? RewriteRule ..../http/%1:80/...
Looks good, thanks a lot. So far I've learned that Apaches rewrite-machinery is rather expensive (in CPU cycles) and my small patch to the VirtualHostMonster is comparably cheap. Are there circumstances where throwing away extra port parameters inside the VHM will cause trouble? Jo. -- Internetmanufaktur Jo Meder ---------------------- Berlin, Germany http://www.meder.de/ ------------------- fon: ++49-30-417 17 63 33 Kollwitzstr. 75 ------------------------ fax: ++49-30-417 17 63 45 10435 Berlin --------------------------- mob: ++49-170- 2 98 89 97 Public GnuPG-Key ---------- http://www.meder.de/keys/jo-pubkey.txt
Jo Meder wrote:
Am 23.10.2002, 20:23 Uhr schrub Dieter Maurer <dieter@handshake.de>:
Some HTTP clients include the port in the "HOST" HTTP header.
Use an Apache "RewriteCond" to strip away the port if it is present:
RewriteCond %{HTTP_HOST} ([^:]*)(:.*)? RewriteRule ..../http/%1:80/...
Looks good, thanks a lot.
So far I've learned that Apaches rewrite-machinery is rather expensive (in CPU cycles) and my small patch to the VirtualHostMonster is comparably cheap.
Well, you can use two rewrite rules instead of one and use a cheaper way of comparing - something like RewriteCond %{HTTP_HOST} ^.*:80$ RewriteRule ..../http/%1/... [L] RewriteRule ..../htto/%1:80/... This may be somewhat cheaper than dieters solution. After that I'm not really sure that your python snippet is really cheaper than the rewrite rule. I'd guess it isn't. cheers, oliver
Jo Meder writes:
Am 23.10.2002, 20:23 Uhr schrub Dieter Maurer <dieter@handshake.de>:
Some HTTP clients include the port in the "HOST" HTTP header.
Use an Apache "RewriteCond" to strip away the port if it is present:
RewriteCond %{HTTP_HOST} ([^:]*)(:.*)? RewriteRule ..../http/%1:80/...
Looks good, thanks a lot.
So far I've learned that Apaches rewrite-machinery is rather expensive (in CPU cycles) and my small patch to the VirtualHostMonster is comparably cheap. Are there circumstances where throwing away extra port parameters inside the VHM will cause trouble? I guess the Apache RewriteCond is less expensive than something in Zope, but both are probably cheap.
In my view, the apache solution is cleaner in that it prevents the construction of an invalid URL. Dieter
participants (3)
-
Dieter Maurer -
Jo Meder -
Oliver Bleutgen