0

I am currently migrating a (working) website to the Windows Azure cloud but am having issues with the UrlRewrite module. The problem is the outbound rules cause an Internal Server Error - the site loads correctly if I disable the rules.

I have checked the order of the modules on the Azure server and it is exactly the same as my local machine and the hosting server. I have disabled static compression with the following line in my web.config:

<urlCompression doStaticCompression="false" doDynamicCompression="true" dynamicCompressionBeforeCache="false" />

Here is an example of the rewrite rule that is causing the issue:

<rule name="cdn rewrite" preCondition="text only">
   <match filterByTags="Img" pattern="^/Images/(.*)$" />
   <action type="Rewrite" value="http://cdn.website.com/{R:0}" />
</rule>

I also have the following precondition defined:

<preCondition name="text only">
   <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/.+$" />
</preCondition>

Don't know if it's relevant or not but the site is MVC4 running inside and extra small 2008r2 instance (osFamily="2").

I have a workaround at the moment with Application Request Routing but I would rather have the URL rewritten as we don't plan on using the Azure CDN for the production site.

Anyone managed to get this working on Azure?

Edit - some more info:

The actual error (reported in firebug) says "NetworkError: 500 URL Rewrite Module Error. - http://website.cloudapp.net/"

There is nothing in the logs either in the event viewer or the actual log file relating to this issue.

Actually fixed it while typing this out - see below

Tom Broad
  • 82
  • 1
  • 11
  • Could you specify the actual error you're getting (take a look at the event viewer via RDP or look at the diagnostic logs)? The error Internal Server Error could be anything. – Sandrino Di Mattia May 31 '12 at 09:56
  • 1
    did you completely read Ruslan's answer here: http://forums.iis.net/t/1165899.aspx there is also a registry entry that must be changed, as well as reordering the modules. Not just disabling the static compression and dynamicbeforecache. Frankly I haven't tried yet that full solution, but it seems that it will not work unless all points mentioned by Ruslan are not satisfied. – astaykov May 31 '12 at 10:10

1 Answers1

0

As noted by astaykov, there is a registry key that also needs modifying for this to work.

I'll add it here for posterity but I imagine its on here already:

reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\Rewrite /v LogRewrittenUrlEnabled /t REG_DWORD /d 0 

You must issue an iisreset command or restart the server before the change takes effect.

original post:

http://forums.iis.net/p/1165899/1937454.aspx#1937454

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Tom Broad
  • 82
  • 1
  • 11