Mixing IP-based and name-based virtual hosts?

Mixing IP-based and name-based virtual hosts?

Post by Mark McWiggi » Thu, 14 Jun 2001 03:27:03



We're hosting some outside customers for whom it's not practical to
change DNS via IP-based virtual hosting, and would now like to add
name-based virtual hosting on top of this for development.

We can't get this to work, however. Is this possible? If so, what's
the trick?

Config file:
--
### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on
your
# machine you can setup VirtualHost containers for them.
# Please see the documentation at
<URL:http://www.apache.org/docs/vhosts/>
# for further details before you try to setup virtual hosts.
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# If you want to use name-based virtual hosts you need to define at
# least one IP address (and port number) for them.
#
#NameVirtualHost 12.34.56.78:80
#NameVirtualHost 12.34.56.78

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
#
#<VirtualHost ip.address.of.host.some_domain.com>

#    DocumentRoot /www/docs/host.some_domain.com
#    ServerName host.some_domain.com
#    ErrorLog logs/host.some_domain.com-error_log
#    CustomLog logs/host.some_domain.com-access_log common
#</VirtualHost>

#<VirtualHost _default_:*>
#</VirtualHost>

DocumentRoot /apache/tti

<VirtualHost 206.213.91.100>
ServerName www.tradetech.net
DocumentRoot /apache/tti
</VirtualHost>

<VirtualHost 206.213.91.101>
DocumentRoot /apache/global
</VirtualHost>

<VirtualHost 206.213.91.102>
ServerName www.uslogisticsinc.com
DocumentRoot /apache/uslogistics
</VirtualHost>

<VirtualHost 206.213.91.214>
DocumentRoot /apache/tti
</VirtualHost>

<VirtualHost 206.213.91.221>
DocumentRoot /apache/etariff
</VirtualHost>

<VirtualHost 206.213.91.215>
DocumentRoot /apache/etariff
</VirtualHost>

<VirtualHost 206.213.91.217>
DocumentRoot /apache/translink
</VirtualHost>

<VirtualHost 206.213.91.218>
DocumentRoot /apache/searchlady
</VirtualHost>

<VirtualHost 206.213.91.222>
DocumentRoot /apache/translink
</VirtualHost>

<VirtualHost 206.213.91.223>
DocumentRoot /apache/searchlady
</VirtualHost>

<VirtualHost 206.213.91.224>
DocumentRoot /apache/splink
</VirtualHost>

<VirtualHost 206.213.91.220>
DocumentRoot /apache/myiix
</VirtualHost>

NameVirtualHost 206.213.91.225

<VirtualHost 206.213.91.225>
ServerName nick.tradetech.net
DocumentRoot /home/nick/web
</VirtualHost>

<VirtualHost 206.213.91.225>
ServerName mark.tradetech.net
DocumentRoot /home/mark/web
</VirtualHost>

<VirtualHost 206.213.91.225>
ServerName adam.tradetech.net
DocumentRoot /home/adam/web
</VirtualHost>

<VirtualHost 206.213.91.225>
ServerName kerri.tradetech.net
DocumentRoot /home/kerri/web
</VirtualHost>

<VirtualHost 206.213.91.225>
ServerName kevin.tradetech.net
DocumentRoot /home/kevin/web
</VirtualHost>

--

Thanks much for any guidance whatsoever.

Mark McWiggins
Tradetech, Inc.

 
 
 

Mixing IP-based and name-based virtual hosts?

Post by John Murtar » Thu, 14 Jun 2001 03:45:26



> We're hosting some outside customers for whom it's not practical to
> change DNS via IP-based virtual hosting, and would now like to add
> name-based virtual hosting on top of this for development.

> We can't get this to work, however. Is this possible? If so, what's
> the trick?

Hope the below helps -- it is a bit of a tutorial:

Before the newer version of the HTTP protocol, each web site had to be
assigned a unique IP address and a VirtualHost block in the config file
- this was the only way for Apache to know which of potentially many web
sites was being requested.  This was  a wasteful use of IP addresses and
the current version of the HTTP protocol, supported by almost all
browsers, directs the browser to not only send the page requested, but
also the name of the web site.  This uses a NameVirtualHost block.  
Let's look at a couple of examples.
Virtual Host

Here is the VirtualHost block we are currently using on our nuts
machine.

<VirtualHost nuts.whmag.com>

    DocumentRoot /home/com/nuts/www
    ServerName nuts.whmag.com
    some lines deleted
</VirtualHost>

The machine "nuts.whmag.com" has an assigned IP address of 63.110.6.207
- in this format the Apache server doesn't really see "nuts.whmag.com",
instead it converts that name to the IP numbers at startup and any
requests arriving at that IP address will be handled by a child server
with the preceding configuration information for DocumentRoot (where the
HTML files are), etc

One nice this about this is you can direct another site name to the
identical IP address, e.g. on our name server we have made an entry for
nuts.thebook.net - and also assigned it the IP address 63.110.6.207.  If
you view http://nuts.thebook.net/ you will see the identical site.  We
offer this service to our customers who want to register multiple domain
names and want an easy way to pull them into one web site.
Name Based Virtual Host

To setup a Name Based site we first tell Apache the IP address that will
be shared by potentially many incoming domains (NameVirtualHost). The
first VirtualHost block is the default, it uses the attribute
ServerName.  If the incoming request to that IP address does not match
that name or one of the ServerAlias entries in the two blocks which
follow, the server will default to the first entry.

NameVirtualHost nuts.whmag.com

<VirtualHost nuts.whmag.com>

    DocumentRoot /home/com/nuts/www
    ServerName nuts.whmag.com         # Only ONE with ServerName
    some lines deleted
</VirtualHost>

<VirtualHost bolts.thebook.net>

    DocumentRoot /home/com/nuts/www/bolts
    ServerAlias bolts.thebook.net     # Alias
    some lines deleted
</VirtualHost>

<VirtualHost jolts.thebook.net>

    DocumentRoot /home/com/jolts/www
    ServerAlias jolts.thebook.net      # Alias
    some lines deleted
</VirtualHost>

Also note that we can specify a different DocumentRoot for each entry.
In the case of bolts.thebook.net, we are directing it to a subdirectory
of a main account. In the last case we are giving it a separate home
area.  The choice is yours!

--
                                                  John
______________________________________________________
Customer Service                 Sofware Workshop Inc.

315-635-1968, x-211            http://www.thebook.com/

 
 
 

Mixing IP-based and name-based virtual hosts?

Post by Joshua Sliv » Thu, 14 Jun 2001 04:11:56




>> We're hosting some outside customers for whom it's not practical to
>> change DNS via IP-based virtual hosting, and would now like to add
>> name-based virtual hosting on top of this for development.

>> We can't get this to work, however. Is this possible? If so, what's
>> the trick?

> Hope the below helps -- it is a bit of a tutorial:

I'll point out three problems in the tutorial:

1. You should always use an IP address rather than a name in
NameVirtualHost and <VirtualHost> directives to avoid creating
a dependency on DNS at server startup.

2. Each name-vhost should have a ServerName directive.  The
ServerAlias directive is only for additional names that you would
like that vhost to respond to, not for the main name.

3. Comments should not be included on the same line as configuration
directives.  (I guess you don't have these in your real config.)

Back to the original questions:

I don't see anything wrong with your config on a quick look.
However, several of the names don't resolve in DNS (eg.
adam.tradetech.net, kevin.tradetech.net)

Perhaps you could let us know exactly what you expect it to
do, and exactly what it is doing.

--
Joshua Slive

http://slive.ca/

 
 
 

Mixing IP-based and name-based virtual hosts?

Post by Mark McWiggi » Thu, 14 Jun 2001 06:02:05


Never mind ... it must have been a permissions problem with some of
them, as adam.tradetech.net now works.

Some of these are new in the DNS and thus may not have percolated out
to the secondary DNS servers yet.

Thanks for your replies.