Hi,
On 08/23/2011 10:42 AM CEST +02:00, Micha Lenk wrote:
> However, I believe the fix is yet incomplete. The function
> ap_matches_request_vhost() used by modules like mod_proxy seems to
> implement the virtual host check also in the wrong order. [...]
>
> I'll follow up with a patch for this function later.
Here you go. Attached is the suggested patch for the function
ap_matches_request_vhost().
Anything else missing?
Regards,
Micha
diff -u4 -r httpd-2.2.19.orig//server/vhost.c httpd-2.2.19.patched//server/vhost.c
--- httpd-2.2.19.orig//server/vhost.c 2010-08-10 21:11:40.000000000 +0200
+++ httpd-2.2.19.patched//server/vhost.c 2011-08-23 12:01:04.247092813 +0200
@@ -820,38 +820,22 @@
server_addr_rec *sar;
s = r->server;
- /* search all the <VirtualHost> values */
- /* XXX: If this is a NameVirtualHost then we may not be doing the Right Thing
- * consider:
- *
- * NameVirtualHost 10.1.1.1
- * <VirtualHost 10.1.1.1>
- * ServerName v1
- * </VirtualHost>
- * <VirtualHost 10.1.1.1>
- * ServerName v2
- * </VirtualHost>
- *
- * Suppose r->server is v2, and we're asked to match "10.1.1.1". We'll say
- * "yup it's v2", when really it isn't... if a request came in for 10.1.1.1
- * it would really go to v1.
- */
+ /* search the <ServerName> and all the <ServerAlias> values */
+ if ((port == s->port) && matches_aliases(s, host)) {
+ return 1;
+ }
+
+ /* Fallback: search all the <VirtualHost> values */
for (sar = s->addrs; sar; sar = sar->next) {
if ((sar->host_port == 0 || port == sar->host_port)
&& !strcasecmp(host, sar->virthost)) {
return 1;
}
}
- /* the Port has to match now, because the rest don't have ports associated
- * with them. */
- if (port != s->port) {
- return 0;
- }
-
- return matches_aliases(s, host);
+ return 0;
}
static void check_hostalias(request_rec *r)