I have two servers: an Ubuntu/Apache web server and a Windows 2008 IIS7 server. I have one external static IP address. All web requests on port 80 are forwarded to my Ubuntu machine. The majority of my sites reside on the Ubuntu server, however, a specific site needs to be hosted out of the Windows 2008 machine. How can I forward requests for a specific Virtual Host on my Apache web server to IIS to another host on my network?

For instance, my Apache machine is and all requests for www.example.com need to be forwarded transparently to All web requests will always go through the Apache machine first.

How can I accomplish this?

  • look into port forwarding using iptables. It's not clear what you mean by "always go through the Apache machine." Do you mean hit the Apache host first, due to network configuration? – mbrownnyc Sep 20 '11 at 14:42
  • My router forwards all requests for port 80 to the Ubuntu server. I can't specify at the router level to send site a to ubuntu and site b to IIS. I have to route those at the application layer. – George Sep 20 '11 at 14:45
  • Looks like Shane has a way to do this below within Apache (using the ServerName directive to note the host). Otherwise, if you're controlling access by IP, you could use iptables, which lives in the network stack on your Ubuntu box, to redirect IP traffic. – mbrownnyc Sep 20 '11 at 15:13

Use mod_proxy:

<VirtualHost *:80>
    ServerName site.to.serve.via.iis
    ProxyPass /
    ProxyPassReverse  /
    ProxyPreserveHost On
| improve this answer | |
  • 1
    As a side note, I had to add On after the ProxyPreserveHost. Without it, Apache complained and wouldn't let me start. – George Sep 22 '11 at 13:54
  • @George Oops, my mistake. Edited. – Shane Madden Sep 22 '11 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.