[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: apache-dns cname-vhost



On 16 Jan 2002, at 11:37, Jesse wrote:

> [...]
>
> And then just let apache handle the name based vhosts?
Is
> it really necessary to have a seperate zone file for each
> vhost?

Since Martin has discussed the bind part, I'll try to
explain the apache bit in somewhat common language.

Think it a two step process.
You have the IP and the domain name.
Step one will only care for the IP, step two only
for the domain name.

Apache will listen to one or several IPs (any IP per
default). When it gets an HTTP request on port 80
(or 443 for https or whatever you configured) it will
read the HTTP request. As defined in RFC 2616 for HTTP 1.1
the name of domain name is send with the HTTP request
(other than in HTTP 1.0)
   GET /index.html HTTP/1.1
   Host: www.yourdomain.com

>From here (step 2) Apache will not care for the IP anymore
and will work with the host name (www.yourdomain.com)

It will try to find a <virtual host> section with
either a matching ServerName or ServerAlias statement.

All you have to do is to make sure a) Apache listens
to right IP(s):
 BindAddress *
 http://httpd.apache.org/docs/mod/core.html#bindaddress
b) you have this/These IP(s) configured to behave
as Name Based Virtual Hosts:
 NameVirtualHost 111.22.33.44
 http://httpd.apache.org/docs/mod/core.html#namevirtualhost
c) your <Virtual host> belongs to that IP
<VirtualHost 111.22.33.44>
VirtualHost can have several IPs or you could even
use _default_ for any IP
http://httpd.apache.org/docs/mod/core.html#virtualhost

The ServerName doesn't even have to be a fully qualified
name. For example, I sometimes add a line to my /etc/hosts
file (or a hosts file in a Windooze directory ;-) like
  192.168.1.1  internaltest
and add a virtual host with
<VirtualHost 192.168.1.1>
  ServerName internaltest
  ...

Now I can just enter "internaltest" in my browser an
my Apache on 192.168.1.1 will respond with the
proper content.

hih,
Marcel


--
   __
 .´  `.
 : :' !   Enjoy
 `. `´   Debian/GNU Linux
   `-   Now even on the 5 Euro banknote!



Reply to: