httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Owen Boyle <...@bourse.ch>
Subject Re: Named Based Virtual servers
Date Thu, 13 Dec 2001 08:52:30 GMT
Matthew Daubenspeck wrote:
> 
> I am using a bunch of name based virtual servers with Apache and Debain.
> All of my domains are in the format of:
> 
> name.com with a DNS CNAME of www.name.com pointing to name.com
> 
> I am using named virtual servers for the www.name.com's and it works great.
> However, if any of the plain old name.com address is used, the first server
> in httpd.conf is served.
> 
> Do I have to add an entry for all of the named possibilities, or is there a
> way to reject any other names except for the ones listed in httpd.conf.

We have a similar situation in that we have a lot of legacy FQDNs in DNS
which should point to our canonical ".com" address. 

One way to do it would be as Runeimp suggests with "ServerAlias" but we
have dozens of old addresses. So, like Billy Harvey, we take advantage
of the fact that when apache receives a "Host:" header and if NBVH is
set up, it searches through the VHs looking for a ServerName match. If
it doesn't find one, it uses the first one.

So we do (as our very first VH):

<VirtualHost 192.168.1.1:80> 
  ServerName any
  RedirectMatch permanent (.*) http://www.canonical-name.com$1
</VirtualHost>

This way, if we get an old address coming in, apache searches the VHs
for the servername, doesn't find it, so goes to the first one, ignores
the ServerName, and so redirects the client to our canonical name. The
redirect has the effect of changing the URL in the client's browser so,
hopefully, educating him that our URL has been updated.

Note that the ServerName argument "any" is not important (since it gets
ignored on the second pass)- we could put "frumious.bandersnatch" there
and it would still work.

Rgds,

Owen Boyle.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message