Received: by taz.hyperreal.com (8.7.5/V2.0) id AAA18323; Mon, 30 Sep 1996 00:28:33 -0700 (PDT) Received: from wired.com by taz.hyperreal.com (8.7.5/V2.0) with ESMTP id AAA18317; Mon, 30 Sep 1996 00:28:31 -0700 (PDT) Received: from re.hotwired.com (re.hotwired.com [204.62.131.130]) by wired.com (8.7.4/8.7.3) with ESMTP id AAA25322 for ; Mon, 30 Sep 1996 00:28:29 -0700 (PDT) Received: (news@localhost) by re.hotwired.com (950413.SGI.8.6.12/8.6.12) id AAA00748; Mon, 30 Sep 1996 00:28:28 -0700 To: new-httpd@apache.org Path: dgaudet From: dgaudet@hotwired.com (Dean Gaudet) Newsgroups: hot.mailing-lists.new-httpd Subject: Re: more problems with Host:'s Date: 30 Sep 1996 07:28:27 GMT Organization: HotWired Ventures Lines: 180 Message-ID: <52nsqr$na@re.hotwired.com> References: <52lifr$dhj@re.hotwired.com> NNTP-Posting-Host: get.wired.com Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@hyperreal.com Argh this code is a mess. I'm looking at check_hostalias, which appears to have been modified between 1.1.1 and 1.2: *** check_hostalias.111 Mon Sep 30 00:13:46 1996 --- check_hostalias.12 Mon Sep 30 00:14:12 1996 *************** *** 1,13 **** ! void check_hostalias (request_rec *r) { char *host = getword(r->pool, &r->hostname, ':'); /* Get rid of port */ ! int port = (*r->hostname) ? atoi(r->hostname) : 0; server_rec *s; if (port && (port != r->server->port)) return; ! if ((host[strlen(host)-1]) == '.') { ! host[strlen(host)-1] = '\0'; } r->hostname = host; --- 1,15 ---- ! static void check_hostalias (request_rec *r) { char *host = getword(r->pool, &r->hostname, ':'); /* Get rid of port */ ! int port = (*r->hostname) ? atoi(r->hostname) : 80; server_rec *s; + int l; if (port && (port != r->server->port)) return; ! l = strlen(host)-1; ! if ((host[l]) == '.') { ! host[l] = '\0'; } r->hostname = host; *************** *** 15,22 **** for (s = r->server->next; s; s = s->next) { char *names = s->names; ! if ((!strcasecmp(host, s->server_hostname)) && ! (!port || (port == s->port))) { r->server = r->connection->server = s; if (r->hostlen && !strncmp(r->uri, "http://", 7)) { r->uri += r->hostlen; --- 17,23 ---- for (s = r->server->next; s; s = s->next) { char *names = s->names; ! if ((!strcasecmp(host, s->server_hostname)) && (port == s->port)) { r->server = r->connection->server = s; if (r->hostlen && !strncmp(r->uri, "http://", 7)) { r->uri += r->hostlen; Notice that the default for the local variable ports was changed from 0 to 80. But then the if statement: if (port && (port != r->server->port)) return; Is always going to return since r->server->port defaults to 0 when no port is specified when configuring a virtualhost. Unfortunately this changed occured during Alexei's huge HTTP/1.1 commit (revision 1.30 of http_protocol.c). What happens when you put Port 80 in each of your virtualhosts? Dean P.S. check_fulluri() will become a performance hog in the future if all requests use "GET http://host/path/ HTTP/x.y" -- it will do a DNS lookup on every hit to find out if host matches its ip. See read_request_line(). It is a hog now on proxies since all requests are of that form. In article , Brian Behlendorf wrote: > >Randy's patch (r->server->next ==> r->server) didn't change a thing. to "fix >it" I had to place the vhost segment for what I was calling the "default" >server at the end. > >Here's the relevant sections from my httpd.conf file. Hyperreal's primary >address is 204.152.144.36. > > Port 8O > ServerName www.hyperreal.com > DocumentRoot /export/pub > ><204.152.144.36 came without a Host: header!!>> > > > ServerName www.grooveneedle.com > ..... > > > > ServerName dev.apache.org > ... > > > > ServerName www.hyperreal.com > Redirect /axiom http://www.hyperreal.com/music/labels/axiom > ...(lots of stuff I want to ONLY apply to www.hyperreal.com)... > > > > ServerName www.apache.org > .... > > > etc... > >In order for www.hyperreal.com to come up as the host for requests without a >Host: header, it must be the *last* of the 204.152.144.36 vhosts. Previously I >had it as the *first*, and accesses were defaulting to dev.apache.org's vhost >section. This is a change that happened recently, as in the last few weeks at >the most. > >Now, THIS is where it gets interesting, and what is a real BUG compared to >just being a confusing aspect of the current config situation. Let's say I >move the vhost segment for www.apache.org in between www.grooveneedle.com and >dev.apache.org. When I do that, EVERY request for dev.apache.org and >www.hyperreal.com get shunted to www.grooveneedle.com. If I move the vhost >segment for www.apache.org in between dev.apache.org and www.hyperreal.com, the >www.grooveneedle.com and dev.apache.org work fine, but www.hyperreal.com gets >shunted to dev.apache.org. It appears that only name-vhost segments before the >first IP-vhost segment are matched! > >It looks like the ONLY acceptible config file format is > > VirtualHost name-vhost1 > VH name-vhost2 > .... > VH default-server > VH IP-vhost1 > VH IP-vhost2 > >Etc. Anyone have evidence to the contrary? Does someone know the code well >enough in this area to find the cause? > >On 29 Sep 1996, Dean Gaudet wrote: >> It doesn't seem screwy to me (mind you, I'm looking at 1.1.1 code): >> >> www.hyperreal.com IN A 204.152.144.36 >> www.grooveneedle.com IN A 204.152.144.36 >> >> s are stacked, so the last in the file is the first >> match found. Unless the request has something to differentiate it -- >> which "GET / HTTP/1.0" doesn't -- you get the first match found in >> find_virtual_server. > >Okay, this is the crux of my misunderstanding/problem statement. I guess >nowhere is the logic "if there's no Host header, default to the 'main' server >on that IP number", and if that's the server's main IP number ("Port", outside >of segments), then it should bind to the same DocumentRoot which sits >outside the segments as well. In fact the logic should check that the >vhost segment with ServerName set to the same as ServerName set outside any > segment is the "default" server; presumably that was put there (as I >did, and I know lots others do) to allow for certain configs to be scoped >locally to the main server, not globally to all servers. > >> Anyhow, since check_serverpath() searches from last to first, >> if you put "ServerPath /" into hyperreal's section it will >> become the default. > >Or rearrange the order, as I did do. Neither this or the above suggestion are >intuitive, nor were they required before sometime in the last two weeks. > > Brian > >--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-- >brian@organic.com www.apache.org hyperreal.com http://www.organic.com/JOBS >