Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting 2 vhost servers behind same ip to work

Status
Not open for further replies.

gitsnshigles

Technical User
Jun 30, 2001
9
0
0
US
Hello...and Happy New Year!!!

i'm trying to add another webserver....

webserver 1 is apache/win me, behind my router/firewall and is successfully serving webpages for 3 vhosts domain names.

i try to ad webserver 2,(apache/Red Hat). i open port 80 for it's ip at the firewall/router, i used kde's little applet thing to configure the httpd.conf with one vhost that is the only vhost defined.

when i giver the ol' browser test...pointing toward domain name on webserver2.... the default(first)vhost is served from webserver 1, even though the domain name i requested is a vhost on webserver 2.


the localhost(127.0.0.1) request on webserver 2 returns the correct index page for the vhost domain.

....also requsting its internal ip address(again from webserver 2 itself) it also returns the index page for the vhost domain directory.

....but when i request webserver internal ip address from a winME machine in my network, it returns the cannot find server error.

if you would like to see the .conf, let me know and i'll put it up.

Thanks and Have A Great Day,
-gitsnshigles



 
UPDATE

i got webserver 2 to return it's vhost's correct index when requesting its internal ip address from another computer on internal network...no more cannot find error messesage.

a request for the vhost domain name on webserver 2 is still returned by the default vhost on webserver1.....
 
I don't think you can have 2 different servers on 2 different machines with the same ip address. The reason is because dns can't be configured that way. At best, the only thing you can do is have one server that points to vhosts on the other machine. For this to work you would have to set the two machines so they see each other and can share files seamlessly via Samba or whatever.
 
when a request for a domain name is pointed toward my external ip, wouldnt it be fowarded to all the internal ip addresses opened to port 80 as configured on the router/firewall?
 
Hi,

The way name based virtual hosting works is that you configure apache to 'listen' to one or more IP addresses and/or ports and you designate that these are using name based vhosts via the NameVirtualHost directive. At that stage the url doesn't come into it at all - this is purely IP and so routing, etc. is important. Hence, if you use a directive like :

NameVirtualHost 192.168.1.1

... if the machine has an interface of that IP address apache will act on http traffic received by examining the URL and choosing a matching vhost - if none match then the first one in httpd.conf is the default. If you use a '*' with NameVirtualHost it just means all interfaces (adapters) on the box :

NameVirtualHost *


You obviously cannot have two machines on the same network with the same IP address or you'll get all manner of problems (first one in the ARP table should always 'win'). Presumably, you don't have that and both boxes are on different addresses.

Now, you should be able to run two apache servers quite happily doing virtual hosts as long as each one is getting its own traffic. If you have five domains and they are all pointed by DNS to the same external (public IP) address then your problem is how to discriminate at the router to send three to one box and the other two to the other box. Routers only act on IP addresses and port numbers and have no way of discriminating based on URL. Presumably the router is performing dnat (destination NAT) to traffic on port 80 and is re-writing the destination address to one of your internal machines. There is no way that it can discriminate at that stage to 'choose' where to send port 80 traffic. In other words, its probably all being re-routed to your winme box and the linux box doesn't get a look in.

What you can probably do is use mod_proxy to redirect vhosts. You would need to set up all the vhost containers on the 'main' apache server (winme) but the linux 'hosted' ones would have a config containing stuff like this :

ProxyRequests on

<VirtualHost EXTERNALIP>
ServerName ProxyPass / </VirtualHost>

(Where 192.168.1.2 is the address on the internal linux apache serve)

You need to have mod_proxy active for this - not too sure if its on by default in win32 . See --> .

Hope this helps
 
zoooooom!! right over my head! see infins? that's why you're the boss 'n I'm just your helper. :eek:) I totally missed the router thing in his 1st post. (not that it woulda helped mind you)
 
I uncommented all the proxy mod stuff in httpd.conf on webserver_1. and set the vhost with ProxyPass

<VirtualHost *>
ProxyPass E:/schenectadyonline/www ServerName <VirtualHost>

it returns a 403 error from webserver_1 ....&quot;You don't have permission to access / on this server&quot;....
when i point to schenectadyonline.com with browser.

if i turn off port80 to webserver1 at the router, webserver2 delivers the apache testpage when browser is pointed to schenectadyonline.com. its not directing it to the document root for the vhost(schenectadyonline.com)
...thats another config issue...i cant get the vhost tweeked right......but at least i know its serving something......
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top