Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to configure IIS to proxy requests based on the incoming hostname. For example, if my proxy server is an IIS server located at, a request to would be proxied to

I have tried to set up a reverse proxy with a URL rewrite rule to rewrite *localhost* to {R:1}{R:2}, but I haven't had any luck. From what I have read, it may only be possible if I specify exactly which servers I want to interact with ahead of time, but in my case, this isn't possible (servers are on EC2 and being dynamically created and killed all the time).

share|improve this question
Alternatively, is there a 3rd party proxy server that will do it for me? – Justin Fyles Mar 15 '12 at 20:19
Download Application Request Routing using the Web Platform Installer. – TristanK Mar 15 '12 at 23:52
@TristanK I installed that and set it up as a reverse proxy with the rewrite rule I want, but it appears to require the server name, meaning that I can't decipher the new server name as part of the URL Rewrite, unless I am missing something – Justin Fyles Mar 16 '12 at 12:15
up vote 0 down vote accepted

It's really not that difficult to set up. Whether it's a wise thing to do though by allowing virtually any domain to proxy to is another thing. You should have some kind of mechanism to limit for which domains you want to proxy.

But anyway, technically you have to set up a reverse proxy with the following URL rewrite rule (with the ARR module installed):

<?xml version="1.0" encoding="UTF-8"?>
                <rule name="ReverseProxy" stopProcessing="true">
                    <match url="(.*)" />
                        <add input="{CACHE_URL}" pattern="^(https?)://(.*?)\.www\.proxy\.com" />
                    <action type="Rewrite" url="{C:1}://{C:2}/{R:1}" />

But you should really add more conditions to limit the domains for which you allow proxying.

share|improve this answer
Will this definitely work with any url? I was under the impression that you could only rewrite to servers within your Site pool? Also, we are accomplishing the domain limiting by setting a single domain from which the requests can come, and sitting these machines behind a load balancer. – Justin Fyles Apr 2 '12 at 14:05
It works fine on my test system. The only problem could be to rewrite URL's in the response with outbound rules because the URL rewrite module can not rewrite URL's in gzip compressed content. – Marco Miltenburg Apr 2 '12 at 21:31

Your Answer


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

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