httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Hartill <r...@imdb.com>
Subject RE: NameVirtualHost
Date Sun, 26 Oct 1997 00:45:19 GMT

Careful you don't tred on the worms about to come out of this can..

The problem with the current system (and the old one too) is that it's
just too damn confusing considering all the different ways people want
to use it and expect it to work. How about this completely different
approach..

=-=-=-=-=-

Add a new directive. For want of a better name 'Service' will do for the
demo:


Service [hostname]:[ip]:[port] some-alias
  with all the []s being optional   e.g.


Service bar.imdb.com::80 registered
   # name based only on port 80 - who cares what IP it came in on
Service us.imdb.com::80 mainserver
   # ditto
Service ::79 otherport
   # catch anything on port 79.
Service foo.imdb.com:169.207.1.255: customer_23
   # any port, name based "foo.imdb.com" but also on IP 169.207.1.255
Service :169.207.1.255: customer_24
   # any port, any name, on IP 169.207.1.255
Service ::: mainserver
   # pickup anything that has not been caught
   # if there are any 'Service' directives there must be a ":::" one too.

<VirtualHost mydefault>
  :  :  : 
</VirtualHost>

<VirtualHost otherport>
  :  :  :
</VirtualHost>

<VirtualHost registered>
  :  :  :
</Virtual>

<VirtualHost customer_24>
  :  :  :
</VirtualHost>

<VirtualHost customer_23>
  :  :  :
</VirtualHost>


-=-=-=-=-=

If a request arrives with attributes 'a:b:c' it can be compared
against each of the 'Service' attributes 'x:y:z'.

foreach x:y:z (Service) {
 score = 0
 if  (x!='' && x!=a) || (y!='' && y!=b) || (z!='' && z!=c)  do next

 score = 1
 if  x!=''   score += 1   # a matching hostname is something to cheer about.
 if  z!=''   score += 2   # a matching port is better than a matching hostname.
 if  y!=''   score += 4   # a matching IP is always the best choice.
}

::: will always score 1 and be a better choice than those rejeted with
a score of 0.

The entry with the highest score is used to choose the VirtualHost config
to use. This way there's no hidden ordering and the logic is reasonably
easy to follow and document.


--
Rob Hartill                              Internet Movie Database (Ltd)
http://www.moviedatabase.com/   .. a site for sore eyes.


Mime
View raw message