Sam Carleton wrote:
> On 2/22/07, Boyle Owen <[EMAIL PROTECTED]> 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:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: [EMAIL PROTECTED]
>   "   from the digest: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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 192.168.0.4, which people can
access from the internet with ip address 66.67.68.69 using port
forwarding and that you have two FQDNs served by the server, say
sub1.server.com and sub2.server.com

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

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

192.168.0.4 sub1.server.com
192.168.0.4 sub2.server.com

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
NameVirtualHost 192.168.0.4:80


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. 192.168.0.4 so the
vhost sections
can all use that IP since apache wont see requests coming in for
127.0.0.1 etc...



<VirtualHost 192.168.0.4:80>
ServerName 192.168.0.4
DocumentRoot /path/to/vhosts/192.168.0.4/public
</VirtualHost>

<VirtualHost 192.168.0.4:80>
ServerName 66.67.68.69
DocumentRoot /path/to/vhosts/66.67.68.69/public
</VirtualHost>

<VirtualHost 192.168.0.4:80>
ServerName sub1.server.com
DocumentRoot /path/to/vhosts/sub1.server.com/public
</VirtualHost>

<VirtualHost 192.168.0.4:80>
ServerName sub2.server.com
DocumentRoot /path/to/vhosts/sub2.server.com/public
</VirtualHost>

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

telnet 192.168.0.4 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
section.

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
this:

<VirtualHost 192.168.0.4:80>
ServerName oops
#DocumentRoot /dev/null
DocumentRoot /path/to/vhosts/oops/public
</VirtualHost>

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
HTTP/1.0</body></html>


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:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to