Since now, I used the vhost feature of apache2 to bind multiple domains to one public and static ip.
Now I'm setting up a XEN Host with 4 IPs, and several VMs, two of them are pure webservers. It's possible for these to 2 VMs to share one public ip? Eachone would have a set of vhosts on the same public ip.
Edit: Okay, what about a Host based redirection?
If you only care about serving http, you most likely want to install a software load balancer / reverse proxy like Pound. The configuration on the Xen host would (again-- most likely) look like
You'll also need to setup forwarding and iptables rules on the Xen host; it may already be setup for that.
As per your edit, you can use a reverse proxy. Apache can do that. Pound is another solution already mentioned.
I don't think you would be able to split the requests going to both servers if they are the same IP?
Why do you need to set them on the same IP?
nice diagram though
As radius and the others say, I don't believe that it's possible to do it just by giving the servers the same IP (they'll complain about duplicate addresses and one of them will end up IP-less), or the same secondary IP (as above, but harder to troubleshoot).
A better option would be either round-robin DNS, where you can add the IPs of each webserver to the same "A" record, and a query for that "A" record will return either a different address each time, or a list of addresses for your clients to choose from. Another option would be to add some kind of load-balancing app in front of the two webservers to route traffic to each one equally (or just to one, with the other as a failvover) You can do this with another instance of Apache with mod_proxy installed.
Which one of these you want to use depends on why you want to do it - are we talking about some kind of high-availability/clustering thing?
You can not have a single IP on both machines at the same time, but you can quickly move it between them.
It seems you're after a load balancing/high availability solution.
I suggest you look into Linux-Ha - Heartbeat [1].
It's basically a daemon that would run on both machines, Webserver 1 and Webserver 2 and send "I'm alive" signals to each other, whenever the signal is not received for a specified amount of time, the other node is assumed dead (or made dead using a STONITH [2] device) and the active node takes everything over.
You can also pick active/passive nodes by hand. Starting from heartbeat v2, it's possible to monitor nodes at resource level, though the configuration is XML based and kind of complex, if you're going to look into it, I suggest using heartbeat-gui to configure it (Ubuntu has a package [3])
Novell has a great free ebook about this stuff [4].
[1] http://www.linux-ha.org/
[2] http://www.linux-ha.org/STONITH
[3] http://packages.ubuntu.com/hardy/admin/heartbeat-gui
[4] http://www.novell.com/documentation/sle_ha/
I don't believe anyone is suggesting two VMs with the same IP. I agree with your reply though. You can't have two machines on the same subnet sharing an IP as you would have an ARP table problem.
The only reason for doing this is load balancing and disaster recovery where if one VM fails, traffic and continue to flow to the other VM; however if the physical hardware fails then both VMs are down so I'm not sure what the value is here or with load balancing. I mean you would be load balancing between two VMs on same physical hardware. What's the goal here?
No, you can't have two servers with the same IP. You will need to get at least one public IP per VM, or do some sort of NATing, but if your going to be serving web pages from these VM's, then you definitely need separate IP's