1

Here's my setup:

Windows Server (2003) receives all traffic for *.mydomain.com, which (up to now) redirects all incoming port 80 traffic to a Linux VM (using VMWare virtual network manager).

I now need to setup another website on this server, using IIS6, to handle subdomain1.mydomain.com.

How do I separate the HTTP traffic as such:

  subdomain1.mydomain.com -> IIS
  everything else (*.mydomain.com, domain.com, raw IP) -> Linux VM

I thought of setting up an Apache server on Windows as Reverse Proxy. But can ProxyPass handle hostnames? (all examples I see handle directories).

Is there another/easier solution? Would lighttpd help?

TIA for your help.

[FWIW: Changing the architecture is not an option. Else I wouldn't ask ;-). An acceptable option if it helps (I doubt though) is to setup a 2nd public IP)]

Serge Wautier
  • 419
  • 1
  • 5
  • 16

1 Answers1

4

You can set up VirtualHosts in Apache, and then use ProxyPass for the subdomain1.mydomain.com to reverse proxy into IIS, and have a default VirtualHost that reverse proxies into your Linux VM.

You'd want a configuration that was something like this:

<Virtualhost *:80>

    ServerName subdomain1.mydomain.com

    ....
    # Reverse proxy into IIS
    ProxyRequests off
    ProxyPass / http://ip.of.IIS.machine/
    ProxyPassReverse / http://ip.of.IIS.machine/
</VirtualHost>

<VirtualHost _default_:80>
    ....
    ProxyRequests off
    ProxyPass / http://ip.of.linux.machine/
    ProxyPassReverse / http://ip.of.linux.machine/        
</VirtualHost>

Those configs are missing most of the configuration, but the important bits are that the first VirtualHost definition matches on subdomain1.mydomain.com, and this then does a reverse proxy into the IIS machine. The second definition matches everything else, and reverse proxies into the linux machine.

Note, I haven't tested the above as it is written, but I have definitely got an apache setup with multiple virtualhosts where one vritualhost is a reverse proxy into another machine, so the basic theory is fine.

Daniel Lawson
  • 5,476
  • 22
  • 27
  • Daniel, thanks! It works. Oddly though, I had to put a ServerName in the _default_ vhost or everything would go to the other one. The only problem is that IIS (localhost, different port) thinks the client is localhost hence, in case of application error, returns a detailed explanation of the error :-( – Serge Wautier Mar 25 '11 at 10:00
  • 1
    Glad it worked for you. Also, setting up a second public IP probably does help - you should (assuming windows does sane things here, I don't know) be able to bind IIS to one of the IPs, and serve it directly, and then forward everything on port 80 on the other IP through to your linux VM, and no apache+reverseproxy needed. – Daniel Lawson Mar 26 '11 at 02:11
  • I know it's super late to suggest this, but maybe adding `ProxyPreserveHost On` above the `ProxyPass` config would fix the problem with IIS thinking its serving clients on localhost? – nevada_scout Feb 14 '20 at 12:46
  • That worked flawlessly! In my scenario, I only needed the `ProxyPass` directive tho. I had 1 apache proxy + 1 webserver with 2 VirtualHosts. I created 2 different VirtualHosts as you described in my apache proxy, redirecting them to the webserver, and it worked!. *PS: I didn't need a default VirtualHost, I used 2 regular VirtualHosts* – Adrián Jaramillo Nov 07 '21 at 14:43