You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Philippe <pb...@abritel.fr> on 2002/03/14 12:02:42 UTC

How configure multiple domains on a same address and port ?

Hello,

I'm trying to configure Apache to serve multiple domains but on the same 
adress and port .
just the directoryRoot change for each domain.

I've tried virtual host but it's the first in the list who capture all 
the request.

How can I do ?

Thanks for your response,

Best regards.

Philippe BARRIELLE
France


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


Re: How configure multiple domains on a same address and port ?

Posted by Philippe <pb...@abritel.fr>.
> Can you post your virtual host config?

#
# 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 192.168.1.253>
ServerName www.servisimmo.com
DocumentRoot /Users/imac/Sites/servisimmo
</VirtualHost>

<VirtualHost 192.168.1.253>
ServerName www.immocpl.com
DocumentRoot /Users/imac/Sites/immocpl
</VirtualHost>

Include /private/etc/httpd/users
ServerTokens OS

<VirtualHost 192.168.1.253>
DocumentRoot /Users/imac/Sites
ServerName php.abritel.fr
ErrorLog /Users/imac/error.txt
</VirtualHost>


<VirtualHost _default_>
DocumentRoot /Users/imac/Sites
</VirtualHost>
>
> Also, make sure your clients are sending requests using proper HTTP 1.1 
> format, ie including a "Host: <blah>" line. If this is missing Apache 
> won't know which host the client is refering to and (I think) defaults 
> to the first server defined.

I use recent browser like IE 5.1 or Netscapt 6.2.


> alex..
>
> Philippe wrote:
>> Hello,
>> I'm trying to configure Apache to serve multiple domains but on the 
>> same adress and port .
>> just the directoryRoot change for each domain.
>> I've tried virtual host but it's the first in the list who capture all 
>> the request.
>> How can I do ?
>> Thanks for your response,
>> Best regards.
>> Philippe BARRIELLE
>> France
>


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


Re: How configure multiple domains on a same address and port ?

Posted by alex dyas <ad...@twowaytv.co.uk>.
Can you post your virtual host config?

Also, make sure your clients are sending requests using proper HTTP 1.1 
format, ie including a "Host: <blah>" line. If this is missing Apache 
won't know which host the client is refering to and (I think) defaults 
to the first server defined.

alex..

Philippe wrote:
> Hello,
> 
> I'm trying to configure Apache to serve multiple domains but on the same 
> adress and port .
> just the directoryRoot change for each domain.
> 
> I've tried virtual host but it's the first in the list who capture all 
> the request.
> 
> How can I do ?
> 
> Thanks for your response,
> 
> Best regards.
> 
> Philippe BARRIELLE
> France


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


Re: How configure multiple domains on a same address and port ?

Posted by James Harr <ja...@grickle.org>.
Hi,

No problem at all, like I said, I banged my head against the wall for a
while until I realized what was going on. It also helps to find apache flow
charts (images.google.com). Here's how apache handles virtual servers:

1) Does the server have a VirtualHost declaration?
  no) Go to default/global server
  yes) Continue on down..
2) Does the server have a NameVirtualHost declaration?
  no) Go to the _ONE_ IP virtual host that is declared
  yes) Search vhost list for the server name in url...
3) Is the matching VirtualHost/ServerName pair for that IP found?
  no) Go to the first VirtualHost for that IP that is declared
  yes) Go to the virtualhost that matches.

And one last thing...

the IP in the <VirtualHost> declaration does not have to match up to the
ServerName inside the container.. The ServerName container is not checked
for validity in terms of whether it matches the DNS for that IP. That's
what's cool about it :)

10.0.0.10/foo.com: nat server/load distributor cluster
10.0.0.11/node1.foo.com: cluster node
10.0.0.12/node2.foo.com: cluster node

in node1/2's apache config, their virtualhosts are set to bind to .11, but
they have 'ServerName foo.com' in there. So that's one way to do
clustering :)

Well, that's overkill, but it'll give you some ideas...

Later,
jh

>>
>> When you say to use a namevirtualhost on that IP, then it basically
>> never goes to the global/default server (although all the servers will
>>  use the defaults from the first server). here's a quick fix for it.
>>
>> After:
>> ServerName grickle.org
>> NameVirtualHost 204.182.60.1
>> <VirtualHost 204.182.60.1>
>>   # Catch all/fall back for this IP.
>>   # This uses all the settings of the global/default server...
>> </VirtualHost>
>> <VirtualHost 204.182.60.1>
>>   ServerName webmail.grickle.org
>>   ....
>> </VirtualHost>
>>
>> I banged my head against the wall for about a week before I figured
>> this out too :)
>>
> My head thanks you.
>
> Best regards,
>
> Philippe B.
>
>
> ---------------------------------------------------------------------
> 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
> 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
For additional commands, e-mail: users-help@httpd.apache.org


Re: How configure multiple domains on a same address and port ?

Posted by Philippe <pb...@abritel.fr>.
>
> When you say to use a namevirtualhost on that IP, then it basically 
> never goes to the global/default server (although all the servers will 
> use the defaults from the first server). here's a quick fix for it.
>
> After:
> ServerName grickle.org
> NameVirtualHost 204.182.60.1
> <VirtualHost 204.182.60.1>
>   # Catch all/fall back for this IP.
>   # This uses all the settings of the global/default server...
> </VirtualHost>
> <VirtualHost 204.182.60.1>
>   ServerName webmail.grickle.org
>   ....
> </VirtualHost>
>
> I banged my head against the wall for about a week before I figured 
> this out too :)
>
My head thanks you.

Best regards,

Philippe B.


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


Re: How configure multiple domains on a same address and port ?

Posted by James Harr <ja...@grickle.org>.
Hi,

The first in the list is the default for that Virtual IP.. This way, if it doesn't find a name based virtual host on that IP, it defaults to the first.. Here's an easy way to fix this:

Before:
# Some global options up at the top
ServerName grickle.org
NameVirtualHost 204.182.60.1
<VirtualHost 204.182.60.1>
  ServerName webmail.grickle.org
  ....
</VirtualHost>

When you say to use a namevirtualhost on that IP, then it basically never goes to the global/default server (although all the servers will use the defaults from the first server). here's a quick fix for it.

After:
ServerName grickle.org
NameVirtualHost 204.182.60.1
<VirtualHost 204.182.60.1>
  # Catch all/fall back for this IP.
  # This uses all the settings of the global/default server...
</VirtualHost>
<VirtualHost 204.182.60.1>
  ServerName webmail.grickle.org
  ....
</VirtualHost>

I banged my head against the wall for about a week before I figured this out too :)

Later,
jh

On Thu, 14 Mar 2002 12:02:42 +0100
"Philippe" <pb...@abritel.fr> wrote:

> Hello,
> 
> I'm trying to configure Apache to serve multiple domains but on the same 
> adress and port .
> just the directoryRoot change for each domain.
> 
> I've tried virtual host but it's the first in the list who capture all 
> the request.
> 
> How can I do ?
> 
> Thanks for your response,
> 
> Best regards.
> 
> Philippe BARRIELLE
> France
> 
> 
> ---------------------------------------------------------------------
> 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
> 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
For additional commands, e-mail: users-help@httpd.apache.org