httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Korthof ...@organic.com>
Subject vhost stuff
Date Wed, 28 May 1997 22:47:09 GMT
I've spent quite a while going over the vhost code.  There are indeed
other bugs, almost all of which are described in some form on the
vhosts-in-depth page (thank you, Dean, for writing this -- it made life
much easier ^_^ ).

The following patch integrates the patch I sent earlier with fixes to some
of these problems, specificially those involving port-based vhosts w/
name-based vhosts (which are currently totally screwed).  It also adds a
little documentation.  I've tested this with a mildly varied environment,
but it probably makes more sense to wait till after 1.2 to use this
(unless others think it should go in now). It is still possible to access
a name-based vhost through a different IP if the ports match, but fixing
that will require a better concept of the identity of the server. 

     -- Ed Korthof        |  Web Server Engineer --
     -- ed@organic.com    |  Organic Online, Inc --
     -- (415) 278-5676    |  Fax: (415) 284-6891 --

*** http_protocol.c.orig	Tue May 27 00:00:16 1997
--- http_protocol.c	Wed May 28 15:15:43 1997
***************
*** 681,687 ****
    server_rec *s;
    int l;
  
!   if (port && (port != r->server->port))
      return;
  
    l = strlen(host)-1;
--- 681,695 ----
    server_rec *s;
    int l;
  
!   /* port is never 0 (unless the client sent 'Host: hostname:0', which makes
!    * no sense.  If this server used a wildcard port, then r->server->port
!    * is the default port of the main server, and r->server->addrs->host_port
!    * is 0.  Also, for the main server, host_port is 0.
!    * So if is not the main server, and r->server->addrs->host_port == 0,
!    * then it's a wild card port.  But if it is the main server, we should
!    * try aliases anyway since name-based vhosts haven't been scaned yet.
!    */
!   if ( (port != r->server->port) && (r->server->addrs->host_port
!= 0) )
      return;
  
    l = strlen(host)-1;
***************
*** 691,696 ****
--- 699,710 ----
  
    r->hostname = host;
  
+   /* this takes us through the whole list of server after our current server
+    * in the config.  Maybe it'd be good to make this
+    * 'for (s=r->connection->base_server ; s ; s = s->next)', in case a name
+    * based vhost occurs earlier (user error, but better to be forgiving)
+    * but not for 1.2.
+    */
    for (s = r->server->next; s; s = s->next) {
      const char *names;
      server_addr_rec *sar;
***************
*** 701,707 ****
  	continue;
      }
  
!     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;
--- 715,727 ----
  	continue;
      }
  
!     /* Now we try to match against ServerName, if configured.
!      * Note that only the last ServerName per server is used.  Again,
!      * ports may not match if this server uses a wildcard port.
!      */
! 
!     if ((!strcasecmp(host, s->server_hostname)) && 
!          ( (port == s->port) || (s->addrs->host_port == 0) ) ) {
        r->server = r->connection->server = s;
        if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
  	r->uri += r->hostlen;
***************
*** 709,717 ****
        }
      }
  
!     /* search all the names from <VirtualHost> directive */
      for( sar = s->addrs; sar; sar = sar->next ) {
!       if( !strcasecmp( sar->virthost, host ) ) {
  	r->server = r->connection->server = s;
  	if( r->hostlen && !strncmp( r->uri, "http://", 7) ) {
  	  r->uri += r->hostlen;
--- 729,741 ----
        }
      }
  
!     /* Now try the names defined by <VirtualHost aaa.bbb.ccc> -- or whatever
!      * DNS returned for the numbers supplied there.
!      */
! 
      for( sar = s->addrs; sar; sar = sar->next ) {
!       if( !strcasecmp( sar->virthost, host ) 
!           && ( ( port == sar->host_port ) || (sar->host_port == 0) ) ) {
  	r->server = r->connection->server = s;
  	if( r->hostlen && !strncmp( r->uri, "http://", 7) ) {
  	  r->uri += r->hostlen;




Mime
View raw message