httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgau...@hotwired.com (Dean Gaudet)
Subject Re: more problems with Host:'s
Date Mon, 30 Sep 1996 05:02:23 GMT
Consider virtualhost_section():

    s->next = main_server->next;
    main_server->next = s;

And this config frag:

<VirtualHost A>
</VirtualHost>
<VirtualHost B>
</VirtualHost>
<VirtualHost C>
</VirtualHost>

Let D be the "default" server... or main_server.. or whatever you want
to call it (http_main variable server_conf).  Then the ->next chain looks
like this: D, C, B, A.

Suppose C, B, and A all have the same ip address.  Then find_virtual_host
will return C's server_rec.  So check_serverpath and check_hostalias
will check the appropriate data for B and A... no need to check C
because if B and A don't match then it'll just stay at C anyhow.

But I'd like to state again that I haven't looked at check_hostalias() too
deeply... I'm certain that check_serverpath starting at r->server->next
works, and so would starting at r->server at the expense of some unneeded
comparison.

It was a lot less confusing before name-vhosts...  I think it's especially
confusing because the hosts are dealt with in reverse config-file order.
This is one of the reasons I proposed a rethink of the syntax for it
all that would lay out the selection order in detail.

Dean

P.S. BTW, the suggestion of "ServerPath /" only works if you don't want
to use ServerPath for any other name-vhost, otherwise it'll always go
to the "serverpath /" server when there's no Host: header.

In article <hot.mailing-lists.new-httpd-199609291503.KAA22428@sierra.zyzzyva.com>,
Randy Terbush  <new-httpd@hyperreal.com> wrote:
>> It doesn't seem screwy to me (mind you, I'm looking at 1.1.1 code):
>
>I just glanced at the 1.1.1 code, and there is little (if any) difference.
>
>With my config file layout, the Zyzzyva server is consistently last
>in the filesystem, and seems to have been the only server effected.
>
>By initializing the loop below to r->server->next, the condition to
>exit this loop is met for the last server in the list before even
>entered. This is definitely as Brian describe with config file order
>being the key. Since the server list is not circular, I don't see
>how this could work.
>
>The code: (1.2)
>
>
>  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;
>	parse_uri(r, r->uri);
>      }
>    }
>
>    if (!names) continue;
>
>    while (*names) {
>      char *name = getword_conf (r->pool, &names);
>
>      if ((is_matchexp(name) && !strcasecmp_match(host, name)) ||
>	  (!strcasecmp(host, name))) {
>	r->server = r->connection->server = s;
>	if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
>	  r->uri += r->hostlen;
>	  r->proxyreq = 0;
>	}
>      }
>    }
>  }
>
>> www.hyperreal.com	IN A 204.152.144.36
>> www.grooveneedle.com	IN A 204.152.144.36
>> 
>> <virtualhost>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.
>> 
>> Regarding the r->server->next in check_serverpath(), I don't see how
>> changing it to r->server affects anything other than performance.  If
>> the if conditional succeeds it will set r->server = r->server.
>> 
>> check_hostalias does other crud, so it's possible that starting at
>> r->server would have a different effect... but if you dig back through
>> read_request (caller of check_hostalias) and into read_request_line
>> you'll see it does similar crud.
>> 
>> Anyhow, since check_serverpath() searches from last <virtualhost> to first,
>> if you put "ServerPath /" into hyperreal's <virtualhost> section it will
>> become the default.
>> 
>> Dean
>> 
>> In article <hot.mailing-lists.new-httpd-Pine.SGI.3.93.960927185805.1394I-100000@fully.organic.com>,
>> Brian Behlendorf  <new-httpd@hyperreal.com> wrote:
>> >
>> >Something is really screwy here.
>> >
>> >Go to http://hyperreal.com/ through Netscape: great, looks gorgeous
>> >
>> >telnet to hyperreal.com port 80, and issue a 
>> >
>> >  GET / HTTP/1.0
>> >
>> >with no other headers, and I get the home page for one of the Host:-header
>> >based home pages, www.grooveneedle.com, which happens to be the last
>> >Host:-header-based vhost section in my httpd.conf.  If I use a Host: header
>> >everything works as it should.  Anyone have any ideas?
>> >
>> >	Brian
>> >
>> >
>> >--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
>> >brian@organic.com  www.apache.org  hyperreal.com  http://www.organic.com/JOBS
>> >
>> 
>
>
>



Mime
View raw message