You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by DuSTiN KRySaK <li...@mailroot.com> on 2003/06/04 01:44:51 UTC

[users@httpd] **Virtual hosts question**

Hi there - I am having a crack at virtual hosts today...

I have 2 hosts...

I set them up like this in the httpd.conf file:

# Use name-based virtual hosting.
#
NameVirtualHost *
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *>
    DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *>
    ServerName host.domain.com
    ServerAdmin someone@domain.com
    ServerAlias host.domain.com *.host.domain.com
    DocumentRoot /var/www/html
    ErrorLog /var/log/httpd/host.domain.com-error_log
    CustomLog /var/log/httpd/host.domain.com-access_log custom
</VirtualHost>

<VirtualHost *>
    ServerName host2.domain.com
    ServerAdmin someone@domain.com
    ServerAlias host2.domain.com *.host2.domain.com
    DocumentRoot /var/www/host2html
    ErrorLog /var/log/httpd/host2.domain.com-error_log
    CustomLog /var/log/httpd/host2.domain.com-access_log custom
</VirtualHost>

My hostnames which work fine if I drop the first:

<VirtualHost *>
    DocumentRoot /var/www/html
</VirtualHost>


But I had added that because I wanted any http requests by IP, etc to come
to the main site (host.domain.com). Now with that entry in there all site
requests are going to the default site.....

How have I fudged my config?


I need:
Hostnames to go to their own site.
Any requests by IP to go to the main site.

Thanks!


   
  .::d::.

• --- THEbeatingsWILLcontinueUNTILmoraleIMPROVES --- •




---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] **Virtual hosts question**

Posted by dnk <li...@mailroot.com>.
So I changed the below as well, and I still had issues - but I figured it
out.... in my virtual site, I had the same entry for ServerName (IE
host.domain.com), as well as for the ServerAlias (IE - host.domain.com
*.host.domain.com).

So I just removed host.domain.com from the ServerAlias (So now it is
ServerAlias *.host.domain.com only) and combined with the below - all is
working.

Thanks everyone!

Dustin
----- Original Message ----- 
From: "DuSTiN KRySaK" <li...@mailroot.com>
To: <us...@httpd.apache.org>
Sent: Wednesday, June 04, 2003 7:06 AM
Subject: Re: [users@httpd] **Virtual hosts question**


> On 6/4/03 6:52 AM, "Joshua Slive" <jo...@slive.ca> spit this out onto my
> computer screen:
>
> > If you are talking about the ServerName, it makes no difference what you
> > use.  As I said, you can use "ServerName blah.blah.blah" with the same
> > effect.  The only important thing is that it does not overlap with any
> > other ServerName or ServerAlias.
> >
> > If you are talking about the <VirtualHost> directive, then you should
> > continue to use "*".
> >
> > Joshua.
> Thanks for clarifying that!!!!!!
>
> Dustin
>
>
> ---------------------------------------------------------------------
> 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: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>


---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] **Virtual hosts question**

Posted by DuSTiN KRySaK <li...@mailroot.com>.
On 6/4/03 6:52 AM, "Joshua Slive" <jo...@slive.ca> spit this out onto my
computer screen:

> If you are talking about the ServerName, it makes no difference what you
> use.  As I said, you can use "ServerName blah.blah.blah" with the same
> effect.  The only important thing is that it does not overlap with any
> other ServerName or ServerAlias.
> 
> If you are talking about the <VirtualHost> directive, then you should
> continue to use "*".
> 
> Joshua.
Thanks for clarifying that!!!!!!

Dustin


---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] **Virtual hosts question**

Posted by Joshua Slive <jo...@slive.ca>.
On Tue, 3 Jun 2003, DuSTiN KRySaK wrote:
> Ok - now here is my next question.. Do I use the internal IP, or the public
> IP? If I use the public, the users within the network will not be able to
> access, etc. Can I add two entries?

If you are talking about the ServerName, it makes no difference what you
use.  As I said, you can use "ServerName blah.blah.blah" with the same
effect.  The only important thing is that it does not overlap with any
other ServerName or ServerAlias.

If you are talking about the <VirtualHost> directive, then you should
continue to use "*".

Joshua.

---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] **Virtual hosts question**

Posted by DuSTiN KRySaK <li...@mailroot.com>.
On 6/3/03 5:34 PM, "Joshua Slive" <jo...@slive.ca> spit this out onto my
computer screen:

> 
> On Tue, 3 Jun 2003, DuSTiN KRySaK wrote:
>> My hostnames which work fine if I drop the first:
>> 
>> <VirtualHost *>
>>     DocumentRoot /var/www/html
>> </VirtualHost>
>> 
>> 
>> But I had added that because I wanted any http requests by IP, etc to come
>> to the main site (host.domain.com). Now with that entry in there all site
>> requests are going to the default site.....
> 
> This is actually a tricky one.  Luckily, I worked through this problem
> with someone else before, so I know the answer:
> Add
> ServerName blah.blah.blah
> to the first <VirtualHost> section (or "ServerName your.ip.address" if you
> prefer).
> 
> If you don't have a servername, apache performs a reverse-lookup on your
> IP address to find one.  This is probably giving it host.domain.com, which
> causes the first vhost to catch all the requests.
> 
> This is a case where the dual-use of ServerName (vhost matching and
> canonical identification) causes a bit of unnecessary confusion.
> 
> Joshua.

Ok - now here is my next question.. Do I use the internal IP, or the public
IP? If I use the public, the users within the network will not be able to
access, etc. Can I add two entries?

Ideas?

Dustin


---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] **Virtual hosts question**

Posted by Joshua Slive <jo...@slive.ca>.
On Tue, 3 Jun 2003, DuSTiN KRySaK wrote:
> My hostnames which work fine if I drop the first:
>
> <VirtualHost *>
>     DocumentRoot /var/www/html
> </VirtualHost>
>
>
> But I had added that because I wanted any http requests by IP, etc to come
> to the main site (host.domain.com). Now with that entry in there all site
> requests are going to the default site.....

This is actually a tricky one.  Luckily, I worked through this problem
with someone else before, so I know the answer:
Add
ServerName blah.blah.blah
to the first <VirtualHost> section (or "ServerName your.ip.address" if you
prefer).

If you don't have a servername, apache performs a reverse-lookup on your
IP address to find one.  This is probably giving it host.domain.com, which
causes the first vhost to catch all the requests.

This is a case where the dual-use of ServerName (vhost matching and
canonical identification) causes a bit of unnecessary confusion.

Joshua.

---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org