Rewrite to external domain not working in Azure website

0

I have a Asp.NET MVC test website in the Standard plan in azure cloud. I am trying to set up a rewrite to an external domain. I followed the steps here: http://ruslany.net/2014/05/using-azure-web-site-as-a-reverse-proxy/

I set up also the ignore rule in the RouteConfig and added the WEBSITE_PRIVATE_EXTENSIONS in the app settings. The log for the XDT transform looks successful but the response is a page not found. The rewrite URL step is also working as I can see it in the trace file. The exact error message in trace file is:

ModuleName IIS Web Core

Notification MAP_REQUEST_HANDLER

HttpStatus 404

HttpReason Not Found

HttpSubStatus 4

ErrorCode The filename, directory name, or volume label syntax is incorrect. (0x8007007b)

Update: I can now confirm the rewrite to the same domain works. However, rewriting to external domain works in the sense that is always going to the home page of the current website.

I am totally out of ideas. Kindly share the wildest you may have! Thank you!

azure
rewrite
asked on Stack Overflow Mar 3, 2015 by mosu • edited Mar 3, 2015 by mosu

2 Answers

1

If you use MVC then the MVC Router intercepts all the requests and they are not seen by ARR thus not forwarded and resulting in a HTTP 404 – File Not Found error.

Fix it by telling MVC Routing to leave your proxy alone by adding:

routes.IgnoreRoute("proxy/{*pathInfo}"); 

to Global.asax

If this does not help then enable failed Request Tracing from the Azure site diagnostics page, produces really helpful info.

Hope this helps.

answered on Stack Overflow Mar 4, 2015 by HighCs
1

Somehow by luck I was able to make this work. After many hours of reading and trying different stuff I carefully looked at the example from Ruslan's blog post.

<?xml version="1.0"?>  
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">  
<system.webServer>  
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false"  
reverseRewriteHostInResponseHeaders="false" />  
</system.webServer>  
</configuration> 

Note that it says reverseRewriteHostInResponseHeaders="false". Well, making this true made my stuff work.

The same old story with copy/paste programming. Sad is that this is the actual example of how you should set it up.

answered on Stack Overflow Mar 5, 2015 by mosu

User contributions licensed under CC BY-SA 3.0