httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matt farey <>
Subject Re: [users@httpd] setting up virtual hosting
Date Thu, 22 Feb 2007 13:58:00 GMT

Sam Carleton wrote:
> On 2/22/07, Boyle Owen <> wrote:
>> > I am back at it and it simply is NOT working.  No matter what I do, I
>> > cannot get to the default web site.
>> It is not clear what you mean by "default web site". Once you start
>> using VHs, the "default web site" becomes the *first* VH in the config.
>> So if you hit the server using IP address only (no hostname) you should
>> get the *first* VH. Is this what happens? If not, what site *do* you
>> get?
> Owen,
> I get what I consider the secondary site.  Which is exactly why I
> asked the following question:
>> > In years past (like five years ago) I had been successful in doing
>> thing,
>> > but that was back when there was only one httpd.conf file.  This SuSE
>> > setup has a ton of files.  Is there some way I can make apache tell me
>> > what it sees as the configuration?
> Is there any way for me to get apache to display the config, the way
> it sees it?  I am guessing I have something backwards so that what I
> want as the default site is getting consumed after the site I want as
> the secondary.
> Sam
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project.
> See <URL:> for more info.
> To unsubscribe, e-mail:
>   "   from the digest:
> For additional commands, e-mail:

Dont be discouraged, the VH section of Apache is predictable and does
work. If you have SeLinux turned on, make sure your paths come under the
control of the apache user. Make sure your server has a static IP.

how is your hosts file set up, and on what IP address is your apache
server bound.

say you have a server with ip address, which people can
access from the internet with ip address using port
forwarding and that you have two FQDNs served by the server, say and

in httpd.conf you bind your server to
#note you dont HAVE to bind to one IP, but it locks things down
#we wont deal with SSL for now

your hosts file on the server machine must
actually point to this IP, NOT to
because your apache server is no longer listening on
so you should have the lines in /etc/hosts as follows

in the main httpd.conf you must have the line
# Virtual hosts
Include conf/httpd-vhosts.conf

# Turn off SSL/TLS for now
#Include conf/httpd-ssl.conf

and in your httpd-vhosts.conf file you must have

now just define the 4 sections
note, some peopl use a * instead of IP, this works
because it says "dont care what the IP is, just look for the host header
and if it matches the value of servername then use the VH that matches."

However we have bound apache to a single static IP. so the
vhost sections
can all use that IP since apache wont see requests coming in for etc...

DocumentRoot /path/to/vhosts/

DocumentRoot /path/to/vhosts/

DocumentRoot /path/to/vhosts/

DocumentRoot /path/to/vhosts/

Now there is one more condition, what if someone forms a request to your
server either using if they are on your LAN, or using if they are out on the internet and does NOT send the hosts
header along with the request.

telnet 80[enter]
GET / HTTP/1.1[enter][enter]

Then apache we see the request but wont have a value of Host to match
against your servername, so in this case it will serve the FIRST Vhost

So the question is what do you place first? Perhaps you dont want
someone to get to any of your sites unless they actually ask for them

well you can have one more vhost section tht acts as a catch all. I use

ServerName oops
#DocumentRoot /dev/null
DocumentRoot /path/to/vhosts/oops/public

placed first this will act as a catch all for any clients who dont go to
your other vhosts.

it has one index file, <html><body>please use a browser that understands

lets deal with SSL once the other vhosts are working.

Matthew Farey

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message