Using Azure Web Site as a reverse proxy

IIS has been supporting reverse proxy configuration since URL Rewrite and Application Request Routing modules were released a few years ago. It is possible to configure an IIS hosted web site to act as a reverse proxy and forward web request to other URL’s based on the incoming request URL path. This is described in details in Reverse Proxy with URL Rewrite v2 and Application Request Routing.

Not too many people know however that the same kind of configuration can be achieved with a web site hosted in Azure Web Sites. This blog post explains the configurations steps to enable that.

For example if I want to forward all the requests that come to to some other URL I’ll need to do two things:

  1. Enable proxy functionality in ARR
  2. Add a proxy rewrite rule

Any site hosted in Azure Web Sites has URL Rewrite and ARR enabled. However the proxy functionality is disabled by default in ARR. To enable that we will use the Azure Site Extension XDT transform which will modify the applicationHost.config file for our site and will enable proxy features.

This is the xdt transform file content to enable proxy:

<?xml version="1.0"?>
<configuration xmlns:xdt="">
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false"
reverseRewriteHostInResponseHeaders="false" />

Create a file named applicationHost.xdt and copy paste this code in there. Then upload this file into the “site” directory of your web site:

After that restart your site for the change to take effect.

Next add the following rewrite rule:

<rule name="Proxy" stopProcessing="true">
<match url="^proxy/?(.*)" />
<action type="Rewrite" url="{R:1}" />

For the purposes of this example I configured proxy to forward all requests to but you can replace it with the target url of your site.  Now if I browse to the url rewrite rule will rewrite the request to a different url and then ARR will forward the request (notice the URL in the browser window. It is still my domain name which confirms that this not an HTTP redirect).

This functionality enables some interesting use cases. For example I could have two separate azure web sites and that can appear as if they are under same hostname but in different subfolders, e.g. and


Thanks to Bill Harts who discovered one additional important configuration step that is required if your site also uses ASP.NET MVC. When MVC is enabled on the web site used as a proxy then the MVC Router intercepts all the requests so they are not processed by ARR. So instead of request being forwarded to a destination server you get HTTP 404 – File Not Found error.

In order to fix this you’ll need to exclude the proxy route from the MVC routes by adding the following code to you MVC application:



ruslany on May 16th 2014 in URLRewrite, WAWS

PoorFairAverageGoodExcellent (8 votes, average: 4.63 out of 5)

40 Responses to “Using Azure Web Site as a reverse proxy”

  1. Gravatar ImageBob responded on 18 May 2014 at 8:38 am #

    Wow, this is super helpful.
    Before your post, there’s NO any official post mention about ARR on azure. Cannot believe it. Without ARR , even in memory cache will hit its bottleneck for session id sync and lookup. Now we feel easy to build up new website on Azure!

  2. Gravatar ImageRich Schoenrock responded on 29 May 2014 at 7:58 am #

    Do you know if Cloud Services have ARR and URL Rewrite enabled by default as well? Or is it just Web Sites?

  3. Gravatar ImageRich Schoenrock responded on 11 Jun 2014 at 12:43 pm #

    In case anyone else is wondering, you must manually enable ARR for Microsoft Azure Cloud Services. :)

  4. Gravatar ImageBill Harts responded on 17 Jun 2014 at 12:35 pm #


    Thanks for writing this. I’m not able to get it working yet. Questions:

    1. You wrote, “Next add the following rewrite rule:” but you didn’t say which file to add it to, is it web.config or applicationHost.xdt? And what directory it should be in?

    2. Is there some way to debug the rules? I’m seeing a cryptic error message in the eventlog.xml file (see below) but it doesn’t really tell me much. Can I enable more detailed logging on Azure that will tell me if the rules are being matched?


  5. Gravatar Imageruslany responded on 17 Jun 2014 at 12:47 pm #

    Hi Bill,

    Yes, the rule should be added to web.config file. As with regards to mode detailed logging – the best way to check how the rewrite rules were applied is to enable Failed Request Tracing for the web site.

  6. Gravatar ImageBill Harts responded on 18 Jun 2014 at 9:37 am #

    Thanks again, Ruslan. I’m still not getting it to work.

    I have followed your instructions exactly, adding the rewrite rule to my web.config and enabling via applicationHost.xdt. When I submit an URL with /proxy on it, the URL Rewrite logic detects it, rewrites it correctly to, but when the ApplicationRequestRouting module runs it gives an ARR_WEBFARM_NOT_ROUTED message and changes the URL back to the original /proxy. This then leads to a NOT FOUND error. I have attached the ferb log below as well as my web.config.

    Any ideas why this isn’t working?

    Thanks in advance.

  7. Gravatar ImageBill Harts responded on 19 Jun 2014 at 7:40 am #

    Further info:
    I verified that the transform is working by looking at Config/applicationHost.config. But it still does not route out. Thanks in advance for any ideas.

  8. Gravatar Imageruslany responded on 19 Jun 2014 at 9:25 am #

    Hi Bill, I replied to you directly in email.

  9. Gravatar ImageBill Harts responded on 19 Jun 2014 at 1:58 pm #

    Thanks, Ruslan. I sent the requested files to your gmail. Let me know if they don’t make it through the firewall.


  10. Gravatar ImageAlex Filman responded on 23 Jun 2014 at 9:46 am #

    You can use
    It is the best online proxy found i have listed some features of it to help you.
    They have no ads.(this is why i like them)
    Supports almost every website.
    Best support for youtube,facebook,myspace and much more.
    They are on seperate private servers.not in a shared host so youget the best performance.
    and the best part is youcan use what ever of the subdomain and access there proxy.
    example: you can access the proxy from * replace * with whatever word you like.

  11. Gravatar ImageRahul Patil responded on 28 Jul 2014 at 4:12 am #

    Hi, Ruslan.

    I want to reverse proxy my azure website ( to domain.

    Basically, what I need is :

    1. My web app is on
    2. API I am consuming is on
    3. I want to make my web app IE8 compatible
    4. But to avoid CORS. I want to implement something like Reverse Proxy so that all the requests made to my API will be through Proxy..

    Will this method help?


  12. Gravatar ImageStanley responded on 06 Aug 2014 at 3:48 am #

    Woops.. below are my web.config

    <?xml version="1.0" encoding="UTF-8"?>
    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
    <match url="*" />
    <action type="Rewrite" url="; />

  13. Gravatar ImageStanley responded on 06 Aug 2014 at 6:33 pm #

    Hi Ruslan,

    Thanks for contributing the guide “Using Azure Web Site as a reverse proxy”. I’m enjoy reading your guide for quite a while. Recently I have implemented Azure Website to act as a reverse proxy for our web servers in test environment.

    I believe the xdt transform was successful based on the log file below.

    2014-08-06T10:43:46 sandboxproc.exe C:\DWASFiles\Sites\ARR-BEM\Temp\applicationhost.config
    2014-08-06T10:43:46 env XPROC_TYPENAME=Microsoft.Web.Hosting.Transformers.ApplicationHost.SiteExtensionHelper, Microsoft.Web.Hosting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    2014-08-06T10:43:46 env XPROC_METHODNAME=Transform
    2014-08-06T10:43:46 Start ‘site’ site extension tranform
    2014-08-06T10:43:46 StartSection Executing InsertIfMissing (transform line 4, 8)
    2014-08-06T10:43:46 on /configuration/system.webServer/proxy
    2014-08-06T10:43:46 Applying to ‘system.webServer’ element (no source line info)
    2014-08-06T10:43:46 Inserted ‘proxy’ element
    2014-08-06T10:43:46 EndSection Done executing InsertIfMissing
    2014-08-06T10:43:46 Successful ‘D:\home\site\applicationHost.xdt’ site extension tranform
    2014-08-06T10:43:46 sandboxproc.exe complete successfully

    I follow your guide but I received an error.

    “The specified CGI application encountered an error and the server terminated the process.”

    Below are the log error.

    HTTP Error 502.3 – Bad Gateway
    There was a connection error while trying to route the request

    Basically I am trying to do is URL Rewrite to (just an example)

    Below are my web.config

    <?xml version="1.0" encoding="UTF-8"?>
    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
    <match url="*" />
    <action type="Rewrite" url="; />

    Appreciate if you can spare some time to look into the issue that i encountered.

    Thanks in advanced. Hope to see your reply soon!


  14. Gravatar ImageMark Rendle responded on 18 Sep 2014 at 8:38 am #

    For this to work, you’ll need to have WEBSITE_PRIVATE_EXTENSIONS set to 1 in the App Settings for the site.

  15. Gravatar ImageChad Lee responded on 29 Nov 2014 at 1:56 pm #

    Thanks for the writeup! I was able to get my site working with this guide.

    If I wanted to add caching ability to my reverse proxy, how would one go about setting that up? E.g., I want the reverse proxy to honor the cache headers of the thing it is proxying and just serve up the content from its cache rather than hitting the underlying site.

  16. Gravatar Imageeddie responded on 11 Feb 2015 at 10:01 am #


    Thanks for the writeup. I’m trying to redirect a page on Azure, and I get the following error:

    You do not have permission to view this directory or page.

    My situation is that I have a URL, we’ll call it that is a utility URL. In subdirectories, there are many unique applications. But the home URL has no purpose. I’d like to redirect it to the company web page….let’s call that

    All I have in the site folder is the .xdt file in your write up.
    All I have in the wwwroot folder is a web.config that is included in your write up.

    Do I need anything else?



  17. Gravatar ImageConstantin responded on 03 Mar 2015 at 3:30 pm #


    I followed the steps in your tutorial but I’m getting a page not found error for external domain rewriting.

    If I use an internal page it works.
    Could please let us know (we are more having this error, see stackoverflow) if other settings are necessary for external domain rewrite?

    Many thanks!

  18. Gravatar Imageashish responded on 17 Apr 2015 at 5:00 am #

    I have same issues with url routing i tried what you suggested still i failed to do that :(
    can you look at this details questions I posted on stackoverflow ?

  19. Gravatar ImageJohan Kronberg responded on 03 Jun 2015 at 1:51 am #

    Good one! I’ve published a small MVC app that allows you to do a bit more in regards to cache and compression settings. Could be an option as well:

  20. Gravatar ImageSteve Resnick responded on 10 Jun 2015 at 10:32 am #

    Any idea how to enable this with Azure Web Apps?

    The instructions start with an Azure Site Extension, but it seems pretty convoluted (, so step 1 is a big hurdle.

  21. Gravatar ImageAlexander Batishchev responded on 10 Jul 2015 at 11:16 am #

    Hey Ruslan,
    Thanks for fixing the site!
    Do you remember how to configure ARR caching in Azure? You post doesn’t mention it and I didn’t find much information about it in Internet.

  22. Gravatar ImageAsrar responded on 10 Mar 2016 at 2:03 am #

    I have implemented this as per the instructions, the reverse proxy is working, but i no longer have access to the original request ip address.

    Is it possible to foward the request ip address onto the webapp.

    Just to add im actually running a java web app undeneath using tomcat.

  23. Gravatar ImageAbdul responded on 15 Jun 2016 at 9:49 pm #

    Hi Ruslan,
    I followed all the steps correctly, for testing purpose my target URL is, the redirect is happening but the URL in the browser also is changing to to which I think should not be happening as you also have pointed in the article, please advise what is wrong

  24. Gravatar ImageMarc responded on 13 Dec 2016 at 5:14 am #


    Is this documentation still applicable now ? I created a new Webapp and copy the applicationHost.xdt in the dite folder and created a new web.config file with the content listed here and uploaded it in the wwwroot folder but all I get when brownsing to my app URL is the content of the hostingstart.html file. Should I have had other files is that wwwroot folder ?

    Thanks in advance,

  25. Gravatar Imagedavid stephenson responded on 05 Jan 2017 at 3:52 am #

    I also followed the instructions above and I get a 303 response code.

    You example ( also returns the same 303

    After several hours of trying different things I could not get it working as a reverse proxy, i.e returning 200 ok with content from

    has Azure changed in some way?

  26. Gravatar Imageruslany responded on 05 Jan 2017 at 9:33 am #

    Hi David,

    Thanks for letting me know about that. This is most likely because site has recently added a rule on their site to enforce HTTPS. For example if you browse directly to you will see that you get HTTP 303 that redirects to httpS://

    Looks like I’ll need to update the article to point my proxy address to some other location that does not enforce https.

  27. Gravatar ImageStephen responded on 16 Jan 2017 at 8:18 am #

    Hi Ruslany,
    I am simply trying to Redirect HTTP requests that come in to my website to be sent to the HTTPS version. I am going through an Azure Application Gateway and have tried everything for just a basic website and can’t seem to get this working. I do not have a DNS name for my domain. This is just for testing, so I’m using this in my redirect string under URL Rewrite. https://{HTTP_HOST}{REQUEST_URI}. Any help would be much appreciated.

  28. Gravatar ImageStephen responded on 16 Jan 2017 at 8:28 am #

    My redirect is working, but the website isn’t coming up.
    If I type in http://server ip (no DNS setup yet), then it gets redirected to https://server ip
    But I’m worried those URL Rewrite codes are not valid for server ip addresses when it says HTTP_HOST. What is my alternative for testing?

  29. Gravatar ImageJavier Callico responded on 12 Oct 2017 at 6:03 am #

    It worked exactly as described for me.


  30. Gravatar ImageDanny Champlin responded on 15 Dec 2017 at 7:52 am #

    About your update (requiring routes.IgnoreRoute(“proxy/{*pathInfo}”); ), I don’t understand why this is required for MVC. Aren’t the web.config server rewrite rules executed before MVC’s routing?

    Any time I want to add a new rewrite rule, will I first have to get a new build released to production that includes this ignore rule?

  31. Gravatar ImageAlin responded on 19 Dec 2017 at 4:36 am #

    Man i want to thank you sooo much for this article !!!
    I tried for 2 days to play with Azure application gateway to realize that it does not do URL rewrite.
    With your solution i fixed my issue in 10 minutes.
    Thanks again !

  32. Gravatar ImageJatin responded on 12 Jan 2018 at 9:58 am #

    I follow all steps,
    But still, it gives 404 Error.
    My website is on Azure in DNN.

    Plz, let me know what other settings it requires.

    Thanks in advance.

  33. Gravatar ImageTom Ellis responded on 06 Mar 2018 at 8:30 am #

    “notice the URL in the browser window. It is still my domain name”

    Not anymore it’s not! My browser shows

  34. Gravatar ImageTom Ellis responded on 06 Mar 2018 at 9:08 am #

    Oh, I see the problem. It’s because is now running under HTTPS! The functionality of this extension can only be seen with an HTTP site.

  35. Gravatar Imageruslany responded on 06 Mar 2018 at 12:38 pm #

    Hi Tom, thanks for reporting this. You are right, the has started to enforce https on all its URLs. I’ll need to find some other site to proxy requests too because I cannot use HTTPS with my custom domain as I haven’t renewed my SSL certificate :)

  36. Gravatar ImageTom Ellis responded on 07 Mar 2018 at 3:16 am #

    After thinking about it some more I realised that it is fine to rewrite to an HTTPS site but you just need to make sure you specify “https” in the URL. The following works fine:

  37. Gravatar ImageTom Ellis responded on 07 Mar 2018 at 3:16 am #

    <action type="Rewrite" url="{R:1}" />

  38. Gravatar Imageruslany responded on 08 Mar 2018 at 2:13 pm #

    @Tom – yes, that fixed it. Thanks for the help!

  39. Gravatar ImageRobert responded on 31 May 2018 at 12:37 pm #

    Hi @ruslany,
    After reading your post I started to implement this for bringing a blog site back to company-main-domain/blog, but I got stuck trying to re-compress the content after overwrite all links from the backed site.
    I was able to set the compression in my local environment(IIS 10) following other of your posts but for

  40. Gravatar ImageRobert responded on 31 May 2018 at 12:42 pm #

    (I hit return accidentally)… IIS.
    Any thought? Is compression supported in azure for reverse proxy sites? Any specific work around like the ones you suggested here: but for azure?
    Thanks in advance.

Trackback URI | Comments RSS

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

XML Markup: If You want to add XML code to the comment please XML encode it first, otherwise the code will not show up.

Recently Published Articles