Apache Server configuration support - Virtual host setup with single IP address problem

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > February 2006 > Virtual host setup with single IP address problem





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Virtual host setup with single IP address problem
Goomba

2006-02-13, 2:54 am

i found an article http://www.apacheweek.com/features/vhost and followed it.
However i must be doing something wrong as it is not working same with
apaches docs.

i have one IP address from my isp, in my router i have all port 80 requests
going to a local ip address 192.168.1.100.

both domains have their A records set to my static IP address provided by my
ISP. the DNS for these domains are through dotsters DNS service.

in apache i set (from apache docs)

NameVirtualHost 192.168.1.100:80

<VirtualHost *>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>


Now when i type in the domain, both servernames go to the first VirtualHost
listed. What am i doing wrong?

TIA


Steve

2006-02-13, 7:50 am

On Mon, 13 Feb 2006 04:58:57 +0000, Goomba wrote:

> i found an article http://www.apacheweek.com/features/vhost and followed it.
> However i must be doing something wrong as it is not working same with
> apaches docs.
>
> i have one IP address from my isp, in my router i have all port 80 requests
> going to a local ip address 192.168.1.100.
>
> both domains have their A records set to my static IP address provided by my
> ISP. the DNS for these domains are through dotsters DNS service.
>
> in apache i set (from apache docs)
>
> NameVirtualHost 192.168.1.100:80
>
> <VirtualHost *>
> ServerName www.domain.tld
> DocumentRoot /www/domain
> </VirtualHost>
>
> <VirtualHost *>
> ServerName www.otherdomain.tld
> DocumentRoot /www/otherdomain
> </VirtualHost>
>
>
> Now when i type in the domain, both servernames go to the first VirtualHost
> listed. What am i doing wrong?
>
> TIA

The domain names must resolve to the ip address stated in the
namevirtualhost directive above on your web server, or else they won't
apply.

Add the records to your /etc/hosts on this server, and it'll work.

Use...


NameVirtualHost 192.168.1.100:80

<VirtualHost www.domain.tld:80>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost www.otherdomain.tld:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>


As your definitions ( well, I hope you at least define separate log files! )

Once you actually get apache to restart without errors, it'll work
properly in real life.


Steve
Goomba

2006-02-13, 8:54 pm


"Steve" <ThisOne@Aint.Valid> wrote in message
news:pan.2006.02.13.09.37.56.838851@Aint.Valid...
> On Mon, 13 Feb 2006 04:58:57 +0000, Goomba wrote:
>
> The domain names must resolve to the ip address stated in the
> namevirtualhost directive above on your web server, or else they won't
> apply.
>
> Add the records to your /etc/hosts on this server, and it'll work.
>
> Use...
>
>
> NameVirtualHost 192.168.1.100:80
>
> <VirtualHost www.domain.tld:80>
> ServerName www.domain.tld
> DocumentRoot /www/domain
> </VirtualHost>
>
> <VirtualHost www.otherdomain.tld:80>
> ServerName www.otherdomain.tld
> DocumentRoot /www/otherdomain
> </VirtualHost>
>
>
> As your definitions ( well, I hope you at least define separate log
> files! )
>
> Once you actually get apache to restart without errors, it'll work
> properly in real life.
>
>
> Steve



im running on windows and my hosts file looks like:

127.0.0.1 localhost
192.168.1.200 mydomain1.com
192.168.1.201 mydomain2.com


my httpd.conf file looks like:

NameVirtualHost 192.168.1.200:80

<VirtualHost www.mydomain1.com:80>
ServerName www.mydomain1.com
DocumentRoot D:\web\domain1\htdocs
</VirtualHost>


<VirtualHost www.mydomain2.com:80>
ServerName www.mydomain2.com
DocumentRoot D:\web\domain2\htdocs
</VirtualHost>

my router is setup to forward all port 80 requests to 192.168.1.200. now
when you type in the domain name it always resolved to the first virtual
host. what am i doing wrong?

TIA









Steve

2006-02-14, 2:55 am

On Mon, 13 Feb 2006 20:15:25 +0000, Goomba wrote:

>
> "Steve" <ThisOne@Aint.Valid> wrote in message
> news:pan.2006.02.13.09.37.56.838851@Aint.Valid...
>
>
> im running on windows and my hosts file looks like:
>
> 127.0.0.1 localhost
> 192.168.1.200 mydomain1.com
> 192.168.1.201 mydomain2.com
>
>
> my httpd.conf file looks like:
>
> NameVirtualHost 192.168.1.200:80
>
> <VirtualHost www.mydomain1.com:80>
> ServerName www.mydomain1.com
> DocumentRoot D:\web\domain1\htdocs
> </VirtualHost>
>
>
> <VirtualHost www.mydomain2.com:80>
> ServerName www.mydomain2.com
> DocumentRoot D:\web\domain2\htdocs
> </VirtualHost>
>
> my router is setup to forward all port 80 requests to 192.168.1.200. now
> when you type in the domain name it always resolved to the first virtual
> host. what am i doing wrong?
>
> TIA


What do you expect? www.mydomain2.com doesn't resolve to 192.168.1.200 -
it doesn't resolve at all!

Change your hosts file to

127.0.0.1 localhost
192.168.1.200 www.mydomain1.com www.mydomain2.com

And restart apache.
Goomba

2006-02-14, 2:55 am


"Steve" <ThisOne@Aint.Valid> wrote in message
news:pan.2006.02.14.03.29.21.745388@Aint.Valid...
> On Mon, 13 Feb 2006 20:15:25 +0000, Goomba wrote:
>
>
> What do you expect? www.mydomain2.com doesn't resolve to 192.168.1.200 -
> it doesn't resolve at all!
>
> Change your hosts file to
>
> 127.0.0.1 localhost
> 192.168.1.200 www.mydomain1.com www.mydomain2.com
>
> And restart apache.



lol, im dumb. didnt know you could list your hosts like that. works like a
charm now. thanks so much!!


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com