httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Evans <tevans...@googlemail.com>
Subject Re: Virtual host and DNS record
Date Thu, 01 Dec 2011 10:01:29 GMT
On Thu, Dec 1, 2011 at 9:34 AM, ipmanux <ipmanux@gmail.com> wrote:
>
> Dear all,
>
> I am using RHEL with HTTPD+TOMCAT, I configured  4 VHOSTs on the same server
>
>   -3 VHOST (named-based)
>          1st  vhost: www.abc.com
>          2nd vhost: www.def.com
>          3rd  vhost: www.ghi.com
>
>   -1 VHOST(IP-based)
>          www.klm.com
>
> My DNS record are  for the 3 VHOST (named-based)   pointing to 192.168.1.2
>  and    for  the  VHOST(IP-based)    pointing to an alias 192.168.1.3
>
> In case someone create a DNS entry pointing to one of my 2 IP address for
> example:
>                   www.someone.com   ->  192.168.1.2
>
> How to config Apache to not respond or redirect to a error page when an end
> user browse this URL:www.someone.com ?
>

The first vhost for a particular vhost spec (eg, the first
<VirtualHost *:80> or the first <VirtualHost 1.2.3.4:80>, depending on
what you have for NameVirtualHost) is the default vhost. When a
request comes in for a domain name that is not served by any of your
vhosts, it will be served from the default vhost.

Hence, if you want unknown domains to error, your first vhost should
handle this. Eg:

<VirtualHost *:80>
    # The default/error vhost, no ServerName required
    DocumentRoot /var/www/sites/error
</VirtualHost>

<VirtualHost *:80>
    ServerName foo.com
</VirtualHost>

Cheers

Tom

Mime
View raw message