title: IIS reverse proxy configuration issues with MVC 5 app
body: <p>I cannot properly configure reverse proxy in IIS 8.5 for my MVC5 application. We use 3rd party application Tibco Spotfire WebPlayer 7.0.1 to integrate into our MVC webapp. To do so we use Javascript API to open report from WebPlayer and insert it into iframe. </p>
  
  <p>We have to configure reverse proxy to allow requests go to backend server with WebPlayer installed. Our main webapp located at <code>http://mywebapp.com/</code> and all requests that should be rewrite looks like <code>http://mywebapp.com/SpotfireWeb/...</code>, backend server located at private ip  <code>http://172.29.1.7/SpotfireWeb/...</code> </p>
  
  <p><strong>The main issue that I configured reverse proxy using ARR 3.0 and URL Rewrite Module 2.0, but it doesn't work for *.ashx, *.aspx, *.axd, *.asmx files. It looks like some handler conflicts with ARR/RewriteModule and doesn't allow to pass requests to different server</strong> </p>
  
  <p><strong>Details</strong>:</p>
  
  <p>When I try to load static html file like <code>http://mywebapp.com/SpotfireWeb/secret.html</code> the request is been rewrote to <code>172.29.1.7</code> server and I got content of this file. But once I request something like <code>http://mywebapp.com/SpotfireWeb/GetJavaScriptApi.ashx?Version=6.0</code> I got <code>404</code> error from mywebapp.com. I run Wireshark and discovered that requests to  back-end server <code>172.29.1.7</code> don't go at all if requests contains *.ashx file.
  I installed <code>Failed Requests Trace</code> and found that event <code>HANDLER_CHANGED</code> occurred which changed <code>ApplicationRequestRoutingHandler</code> to <code>System.Web.Mvc.MvcHandler</code>
  <a href="https://i.stack.imgur.com/vAxVT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vAxVT.png" alt="Failed Requests Trace"></a></p>
  
  <p>Playing with this I removed some handlers and now Wireshark catches requests to the back-end server. I believe this approach of removing handlers is not correct. May be I configured something in wrong way?
  <a href="https://i.stack.imgur.com/zptqv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zptqv.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/y7K69.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y7K69.png" alt="web.config"></a></p>
  
  <p>Anyway, removing one module by one I faced issue when POST request to <code>http://mywebapp.com/SpotfireWeb/AjaxService.asmx/InitiateOpen</code> didn't  processed and I got 404 error from my initial app. When I removed *.asmx handler I still got the same error. This is point where I get stuck right now.</p>
  
  <p><a href="https://i.stack.imgur.com/FY4zX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FY4zX.png" alt="Trace from IE"></a></p>
  
  <p>My rewrite rules from web.config of mywebapp.com. I configured it at website level:</p>
  
  <pre><code>        &lt;rewrite&gt;
          &lt;rules&gt;
              &lt;rule name="ReverseProxyInboundRule1" enabled="true" stopProcessing="true"&gt;
                  &lt;match url="SpotfireWeb/?(.*)$" /&gt;
                  &lt;action type="Rewrite" url="http://172.29.1.7/SpotfireWeb/{R:1}" logRewrittenUrl="true" /&gt;
                  &lt;serverVariables&gt;
                      &lt;set name="ORIGINAL_HOST" value="{HTTP_HOST}" /&gt;
                  &lt;/serverVariables&gt;
              &lt;/rule&gt;
          &lt;/rules&gt;
          &lt;outboundRules&gt;
              &lt;clear /&gt;
              &lt;rule name="ReverseProxyOutboundRule1" preCondition="" enabled="true"&gt;
                  &lt;match filterByTags="A, Area, Base, Form, IFrame, Img, Input, Link, Script" pattern="SpotfireWeb/?(.*)" /&gt;
                  &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="true" /&gt;
                  &lt;action type="Rewrite" value="http://mywebapp.com/SpotfireWeb/{R:1}" /&gt;
              &lt;/rule&gt;
              &lt;rule name="ReverseProxy_Redirection" preCondition="IsRedirection" enabled="true"&gt;
                  &lt;match filterByTags="A, Area, Base, Form, IFrame, Img, Input, Link, Script" serverVariable="RESPONSE_Location" pattern="^http://[^/]+/(.*)" /&gt;
                  &lt;conditions logicalGrouping="MatchAll" trackAllCaptures="true"&gt;
                      &lt;add input="{ORIGINAL_HOST}" pattern=".+" /&gt;
                      &lt;add input="{URL}" pattern="^/(SpotfireWeb)/?.*" /&gt;
                  &lt;/conditions&gt;
                  &lt;action type="Rewrite" value="http://{ORIGINAL_HOST}/{C:1}/{R:1}" /&gt;
              &lt;/rule&gt;
              &lt;preConditions&gt;
                  &lt;preCondition name="IsRedirection"&gt;
                      &lt;add input="{RESPONSE_STATUS}" pattern="3\d\d" /&gt;
                  &lt;/preCondition&gt;
              &lt;/preConditions&gt;
          &lt;/outboundRules&gt;
      &lt;/rewrite&gt;
  </code></pre>
  
  <p>Have anyone saw something similar ?
  I assume that root cause in MVC handler, but can't understand where. </p>