You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Matthew Daubenspeck <ma...@oddprocess.org> on 2001/12/13 03:04:42 UTC

Named Based Virtual servers

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.

That sounds confusing as hell, but I can't think of another way to phrase it...


---------------------------------------------------------------------
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


Re: Named Based Virtual servers

Posted by List Account <li...@wjcc.org>.
Very interesting idea!

WJ
----- Original Message -----
From: "Billy Harvey" <Bi...@thrillseeker.net>
To: <us...@httpd.apache.org>
Sent: Wednesday, December 12, 2001 9:15 PM
Subject: Re: Named Based Virtual servers


> On Wed, 2001-12-12 at 21:04, 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.
> >
> > That sounds confusing as hell, but I can't think of another way to
phrase it...
>
> Matthew - I think you're asking how to serve a default page if someone
> comes to the raw IP address?  Since I constantly have people probing my
> IP address (virus weenies), I created an entry for the first named host
> that would redirect them away:
>
> NameVirtualHost *
>
> <VirtualHost *>
>   ServerName google.com
>   ServerAdmin webmaster@rhinocomputing.com
>   DocumentRoot /var/www/default
>   ServerAlias google.com *.google.com
> </VirtualHost>
>
> and in that directory I have some files that are useful:
>
> default.ida
> index.php
> robots.txt
>
> default.ida has some php code in it:
>
> <?
> header("Location: http://www.microsoft.com");
> ?>
>
> and index.php has:
>
> <?
> header("Location: http://microsoft.com");
> ?>
>
> to give those search engines that ignore the robots file something to
> index.  The robots file has:
>
> User-agent: *
> Disallow: /
>
> So, if someone probes my IP address instead of any of my virtual
> domains, hopefully they will get nothing and be redirected away.
>
> Billy
>
>
> ---------------------------------------------------------------------
> 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
>


---------------------------------------------------------------------
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


Re: Named Based Virtual servers

Posted by Billy Harvey <Bi...@thrillseeker.net>.
On Wed, 2001-12-12 at 21:04, 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.
> 
> That sounds confusing as hell, but I can't think of another way to phrase it...

Matthew - I think you're asking how to serve a default page if someone
comes to the raw IP address?  Since I constantly have people probing my
IP address (virus weenies), I created an entry for the first named host
that would redirect them away:

NameVirtualHost *

<VirtualHost *>
  ServerName google.com
  ServerAdmin webmaster@rhinocomputing.com
  DocumentRoot /var/www/default
  ServerAlias google.com *.google.com
</VirtualHost>

and in that directory I have some files that are useful:

default.ida
index.php
robots.txt

default.ida has some php code in it:

<?
header("Location: http://www.microsoft.com");
?>

and index.php has:

<?
header("Location: http://microsoft.com");
?>

to give those search engines that ignore the robots file something to
index.  The robots file has:

User-agent: *
Disallow: /

So, if someone probes my IP address instead of any of my virtual
domains, hopefully they will get nothing and be redirected away.

Billy


---------------------------------------------------------------------
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


Re: Named Based Virtual servers

Posted by RuneImp <ru...@imptech.net>.
You have to add a ServerAlias line in each of your VirtualHost
directives like so:

        ServerName www.imptech.net
        ServerAlias imptech.net


-=- RuneImp
ImpTech - Web Design, Hosting & Computer Tech
http://imptech.net
rune@imptech.net


----- Original Message ----- 
From: "Matthew Daubenspeck" <ma...@oddprocess.org>
To: <us...@httpd.apache.org>
Sent: Wednesday, December 12, 2001 6:04 PM
Subject: Named Based Virtual servers


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.

That sounds confusing as hell, but I can't think of another way to phrase it...



---------------------------------------------------------------------
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


Re: Named Based Virtual servers

Posted by Owen Boyle <ob...@bourse.ch>.
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