Re: [SLUG] Alias my Loopback?

From: Andrew M Hoerter (amh@pobox.com)
Date: Thu Jun 05 2003 - 23:04:56 EDT


On 5 Jun 2003, Russ Wright wrote:

> So I figure, I'll create virtual hosts and set up different Document
> Roots for each of them...right? So I have multiple choices for virtual
> hosts.I can have an IP based or a name based. However, both require an
> IP address.

You're on the right track, but it's a little less complicated than you
seem to think. For each virtual host, have a stanza like this in your
Apache config file:

<VirtualHost *>
ServerName www.foo.example.com
DocumentRoot /some/where/else
# other directives go here, bla bla bla
</VirtualHost>

Before all the VirtualHost entries, you want this directive:

# Generic binding for anything not matched by a more specific entry
NameVirtualHost *

In effect, this stuff says to "listen" for virtual host connections on all
available IP addresses, and then dispatch each request to an appropriate
VirtualHost entry depending on the name in the HTTP request (name-based
virtual hosting).

Now, you only need to make sure that "www.foo.example.com" (or whatever
your virtual host is) correctly resolves to an IP address that corresponds
to your machine. This can be 127.0.0.1 if you want, assuming Apache is
binding to your loopback address (which I'm pretty sure is the default).
You could place an entry in your /etc/hosts file, in DNS, or whatever is
appropriate for your situation. If other machines on a network will need
to access these virtual hosts, then obviously you will want to put a real
address in DNS.

HTH.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:16:39 EDT