My question is pretty much identical to the question listed but they did not get an answer as they ended up using Linux as the reverse proxy.

Using IIS7 as a reverse proxy

I need to have IIS the main site and linux (Apache) being the proxied site(s).

so I have

site1.com (IIS7) site2.com (Linux Apache)

they have subdomains of

sub1.site1.com sub2.site1.com


I want all traffic to go to site1.com and to say anything that is site2.com should be proxied to linux box on internal network, (believe ARR can do this but not sure how).

I can not have it running as Apache doing the proxying as I need IIS exposed directly.

any and all advice would be great.


I think this might help me:

<rule name="Canonical Host Name" stopProcessing="true">    
    <match url="(.*)" />    
        <add input="{HTTP_HOST}" negate="true" pattern="^cto\.com$" />  
        <add input="{HTTP_HOST}" negate="true" pattern="^antoniochagoury\.com$" />   
        <add input="{HTTP_HOST}" negate="true" pattern="www.antoniochagoury\.com$" />   
    <action type="Redirect" url="http://www.cto20.com/{R:1}" redirectType="Permanent" />    

from: http://www.cto20.com/post/Tips-Tricks-3-URL-Rewriting-Rules-Everyone-Should-Use.aspx

I will have a look at this when I have access to the IIS7 box.


  • Why exactly do you need IIS "exposed directly"? – John Gardeniers May 18 '10 at 12:17
  • I will be using WCF and a number of other services and I do not want these all going through a proxy before they are handled by IIS. Previously had some issues with webservices when they went through an Apache proxy. The linux box just runs some old php and static content (mainly) and will have no problem being proxied. Windows was a bit more "fussy". – Jon May 18 '10 at 12:30
  • I think it might be possible if I can proxy on the host value – Jon May 18 '10 at 15:17
  • Have not been able to get it to work. I setup an IIS site for each website and used rewrite rules. It forwarded it to the other server but seemed to mess with the header so that Apache didn't know which site to serve up. – Jon May 18 '10 at 21:29
  • I don't understand why you're proxying anything. Why don't you burn another public IP from your subnet and statically assign that or NAT (port forward) to your Linux box and change the DNS accordingly? – gravyface Jul 22 '13 at 2:23

I swear this has been answered several times already.

You need to add two pieces of software to IIS to use it as a reverse proxy: URL rewrite and application request routing (ARR). Both can be downloaded from the IIS web site.

The documentation to get you started can be found there.


Your edit mentions it, that HTTP_HOST is the server variable for the domain name. You have a couple options. If the Apache server is publicly exposed, you can use a redirect like you have there.

You need a back reference to the URL so that are unique bindings per site.

For example, add a 4th condition, and make sure that it's at the bottom:

(that means -anything- -dot- -anything(but a dot)- -dot- -anything(but a dot)-)

Now {C:1} will be a back reference to your 2nd level domain, without the TLD. i.e. site1, site1.

In your action, you can use something like this:

Then you can create bindings in Apache for site1.cto20.com, site2.cto20.com, etc.

The other option is to setup ARR and use a reverse proxy rather than a redirect. That retains the original URL and your Apache server doesn't need a public URL or IP. Your rewrite rules can be similar so that each URL hits a different site on the Apache server.

  • Hi, the Apache machine is not publicly visible. I have been having issues with subdomains with the rewrite. I need to investigate further before I fully reply with that here. Thx – Jon May 19 '10 at 14:44
  • In that case ARR is the way to go. Use similar URL Rewrite rules but use ARR to proxy the requests. – Scott Forsyth - MVP May 19 '10 at 15:54

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.