[Zope] apache + vhm & http-rfc compliance

Oliver Bleutgen Oliver Bleutgen <myzope@gmx.net>
Sun, 20 Jan 2002 20:17:05 +0100


> Yeah, I was thinking that that looked problematic but hadn't gotten arou=
nd
> to testing it though.  I'm a bit confused with your solution though:

>> RewriteCond %{HTTP_HOST} ^.*:80$
>> RewriteRule ^/(.*)
>>
> http://localhost:25080/zopefolder/VirtualHostBase/http/%{HTTP_HOST}/Virt=
ua
> lH
> ostRoot/$1 [P]
>>
> http://localhost:25080/zopefolder/VirtualHostBase/http/%{HTTP_HOST}/Virt=
ua
> lH
> ostRoot/$1 [P]

> You seem to indicate that this is working for you but I would have thoug=
ht
> that you would have cared more about SERVER_PORT, not HTTP_HOST...I don'=
t
> think HTTP_HOST is supposed to have the port on it, is it?

Sadly (and IMO inconsistently) it is:
=46rom the http/1.1 rfc:

14.23 Host

   The Host request-header field specifies the Internet host and port
   number of the resource being requested, as obtained from the original
   URI given by the user or referring resource (generally an HTTP URL,

   as described in section 3.2.2). The Host field value MUST represent
   the naming authority of the origin server or gateway given by the
   original URL. This allows the origin server or gateway to
   differentiate between internally-ambiguous URLs, such as the root "/"
   URL of a server for multiple host names on a single IP address.

       Host =3D "Host" ":" host [ ":" port ] ; Section 3.2.2


> I would think a solution *like* this would be most flexible (at its
> simplest):

> <VirtualHost *>
>   RewriteEngine On
>   RewriteRule ^/(.*)
> http://127.0.0.1:8080/VirtualHostBase/http/%{HTTP_HOST}:%{SERVER_PORT}/$=
1
> [L,P]
> </VirtualHost>

This may yield a rewriting to

[...]VirtualHostBase/http/yourhostname:80:80/$1

Try wget or curl on a host configured like you wrote. You won't be able
to get anything from this host, because both will send the hostname with
trailing port. This might be desired in some cases (locking out wget&frien=
ds)
, but will end in a disaster if a popular browser begins to send the "Host=
:"=20
header this way.


> I'll try to check it out myself on a test machine, but are there any
> Apache
> gods who can bless or curse this approach, as it were?

IANAAG, but I really checked everything I wrote. There might be a shorter
way of configuring apache, but I'm pretty confident that we have to take
the trailing port into account.

> Gary

cheers,
oliver