Forum Moderators: phranque

Message Too Old, No Replies

Hosting Multiple Sites

How to configure apache for multiple domains on a single ip

         

stevefowler

10:05 am on Feb 12, 2005 (gmt 0)

10+ Year Member



Hi

I'm running windows 2000 with apache 2. I need to configure the server to host two web sites. I have setup the virtual hosts and it works fine when I try to access the two sites on the server. But when I try to access the second site over the internet all I get is the first site.

I have set the two domains up to point to the same IP address. Should I forward them onto a certain page i.e.

[x.x.x.x...]
[x.x.x.x...]

Thanks

coopster

5:38 pm on Feb 12, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, stevefowler.

Have you had a look through the Apache Virtual Host documentation [httpd.apache.org] yet? There are examples in there that should get you over the hump. Pay special attention to the Listen directives and Name based vs. IP based hosting and look through the examples.

stevefowler

11:26 am on Feb 13, 2005 (gmt 0)

10+ Year Member



I've been through the documentation but I think the problem lies with the domain name and how they are forwarded onto my machine.

I have two options on the web forwarding, either framed or non-framed. The non-framed leaves the ip address of my server in the title bar and the framed replaces the ip address with the domain name.

I have set the two domains up to use framed forwarding

www.site1.co.uk >> [x.x.x.x...]
www.site2.co.uk >> [x.x.x.x...]

If go to another machine over the internet and enter www.site2.co.uk, it shows www.site2.co.uk in the browser but it actually displays site1's web site.

Again if I try this on the server itself it works fine, so it must be how the request is coming in to the server over the internet.

This is how my httpd.conf is setup

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.site1.co.uk
ServerAlias site1.co.uk *.site1.co.uk
DocumentRoot C:/home/site1
</virtualhost>

<VirtualHost *:80>
ServerName www.site2.co.uk
ServerAlias site2.co.uk *.site2.co.uk
DocumentRoot C:/home/site2
</virtualhost>

jdMorgan

6:55 pm on Feb 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



stevefowler,

Welcome to WebmasterWorld!

A simple solution would be to bypass the "forwarding" and simply point the DNS records for both domains to your IP address. The forwarding function is probably dropping the hostname header from the request, so your server can't see it. Without that header, name-based hosting won't work.

Jim

stevefowler

7:42 pm on Feb 13, 2005 (gmt 0)

10+ Year Member



I think I have cracked it.

I have now set the second domain up to point to a folder within the first site.

<VirtualHost *>
ServerName www.site1.co.uk
ServerAlias site1.co.uk *.site1.co.uk
DocumentRoot "C:/home/site1"
</virtualhost>

<VirtualHost *>
ServerName www.site2.co.uk
ServerAlias site2.co.uk *.site2.co.uk
DocumentRoot "C:/home/site1/site2"
</virtualhost>

I then forwarded the two domains as

www.site1.co.uk >> [x.x.x.x...]
www.site2.co.uk >> [x.x.x.x...]

I realise its not using the vistrualhost as such when its coming in over the internet but it will do.

Thanks

Steve