Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a single ESXi 5 server which is connected to a single IP address. Within this server I have created 2 VMs:

  1. Windows 2008 IIS Web Server (a.site.com)
  2. CentOS Apache Web Server (b.site.com)

I am unsure of how to route traffic to the correct VM based on the host header?

share|improve this question

migrated from superuser.com Oct 27 '11 at 16:47

This question came from our site for computer enthusiasts and power users.

    
they listen on different ports, I think –  Lazy Badger Oct 26 '11 at 15:24
    
What device or software is going to do the routing? –  David Schwartz Oct 26 '11 at 16:11
    
@David can the ESXi server itself do the routing? I've got no idea to be honest. –  user35072 Oct 26 '11 at 18:14
    
I don't know of any web routing software that runs on ESXi itself. Something is going to have to receive the connection, look at the 'Host' header, and then either redirect or proxy the returned page. –  David Schwartz Oct 26 '11 at 18:32
1  
Vote to move to Serverfault. –  BBlake Oct 26 '11 at 19:27
add comment

2 Answers

You need to put a reverse proxy on the host machine (or on one of the VMs to which you'll route all requests), which will internally forward requests to individual VMs based on the host header. Both VMs must be accessible from the host machine on a specific IP address or port.

As for the reverse proxy - one option is Apache with mod_proxy, Nginx is a lightweight alternative. According to this post, nginx can be configured as a reverse proxy which works based on Host value as well.

(Disclaimer: I didn't do this practically myself.)

share|improve this answer
1  
Async servers like Nginx and Varnish that were largely designed to reverse-proxy are great fits here, but the lightest-weight (not necessarily fastest) option would definitely be to piggyback on the existing Apache instance and proxy some subdomains to the IIS host. –  jgoldschrafe Oct 27 '11 at 17:35
add comment

I have done this with IBM HTTP Server (IHS) which I don't believe is free, but my favorite GPL version of a reverse proxy is Pound (www.apsis.ch/pound/). Check out the section "Virtual Hosts (In General)" on that page. I believe this is what you are looking for. Below is a slightly tweaked version of the config from that page...

 ListenHTTP
            Address 1.2.3.4
            Port    80

            Service
                HeadRequire "Host: .*a.site.com*"

                BackEnd
                    Address 192.168.0.10
                    Port    80
                End
            End

            Service
                HeadRequire "Host: .*b.site.com.*"

                BackEnd
                    Address 192.168.0.10
                    Port    80
                End
            End
        End
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.