3

I'm trying to set up a virtual machine host (currently running ubuntu + KVM) which will host a number of VMs for different applications. For example, we have a wiki running on one VM and a web application running on another.

     Host
     /  \ 
    VM1 VM2

Internally, the VMs live on their own virtual network with their own IPs, however externally, there is only one IP address which is the IP address of the host.

There is a domain set up on our network that points to the Host's IP and I can set up an iprule to forward traffic destined for the host directly to one of the VMs. However, in order to make both VMs accessible to the outside world, somehow I need to forward requests based on the URL.

Ideally I'd like to forward requests by subdomain e.g.

http://vm1.host/ -> host -> VM1
http://vm2.host/ -> host -> VM2

but alternatively by the URL path:

http://host/vm1 -> host -> VM1
http://host/vm2 -> host -> VM2

I have already installed Apache on the Host machine. What kind of forwarding/redirecting/aliasing/reverse-proxying rules would I need to get this kind of network setup to work? Is there anything extra needed to handle subdomains?

Alex Spurling
  • 131
  • 1
  • 3

3 Answers3

1

Are you serving any webpages from the Host itself? If not, and all of the web data is on VM1 and VM2, then probably Apache on the Host is not the best solution. Most likely you should use something like haproxy or squid on the host to forward the requests to Apache running on VM1&2

davr
  • 1,729
  • 3
  • 14
  • 25
  • No, Host itself is not serving anything at the moment but I will definitely look into those proxy tools as an alternative to Apache. – Alex Spurling Jul 28 '09 at 22:29
  • +1 for the proxy. Even web servers like lighttpd/nginx provide a proxy mode that works well in this situation. – sybreon Jul 29 '09 at 04:05
0

I have somewhat similar environment, where I need to forward stuff from one host to another, so I use Apache's mod_proxy http://httpd.apache.org/docs/2.2/mod/mod_proxy.html I hope that helps, you can also utilize Virtual Host http://httpd.apache.org/docs/2.2/vhosts/

alexus
  • 13,112
  • 32
  • 117
  • 174
0

I think using Apache on the host is fine. This is basically the same situation as this serverfault post, you want some sort of reverse proxy.

Kyle Brandt
  • 83,619
  • 74
  • 305
  • 448