URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt [Answered]RSS

10 replies

Last post Mar 06, 2013 09:48 AM by OWScott

  • URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 04, 2013 08:30 AM|doulos2k|LINK

    I swear I had this working prior to the last round of Windows Updates, but now I can't figure out for the life of me what's going on.

    Here's the Rewrite entry in the web.config (names changed):

    <rewrite>
    	<rules>
    		<rule name="Reverse Proxy 1">
    			<match url="^blog(/)?$" />
    			<serverVariables>
    				<set name="HTTP_X_CUSTOM_HEADER" value="b99f2a-6ef1-7bba-11de-ff6b1ee377" />
    			</serverVariables>
    			<action type="Rewrite" url="http://www.example.com/" />
    		</rule>
    		<rule name="Reverse Proxy 2">
    			<match url="^blog(/.*)?$" />
    			<serverVariables>
    				<set name="HTTP_X_CUSTOM_HEADER" value="b99f2a-6ef1-7bba-11de-ff6b1ee377" />
    			</serverVariables>
    			<action type="Rewrite" url="http://www.example.com/blog{R:1}" />
    		</rule>
    		<rule name="Redirect Everything to Wordpress Home">
    			<match url=".*" />
    			<conditions logicalGrouping="MatchAll">
    				<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    				<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    			</conditions>
    			<action type="Rewrite" url="index.php" />
    		</rule>
    	</rules>
    </rewrite>

    Application Request Routing has been enabled with all settings at their defaults. Before I ran updates and restarted the server last week, going to /blog, pulled content from our blog partner without issue. Now, when I go to /blog, I get the following:



  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 02:20 PM|doulos2k|LINK

    Annnd... we're stumped? Ugh. I'm really baffled here. I have no idea why it's throwing this error at all.

  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 02:39 PM|OWScott|LINK

    There are a few errors that could cause that.

    Here's one way to find out more details about the error: http://weblogs.asp.net/owscott/archive/2010/03/25/500-50-error-using-url-rewrite.aspx

    It could be a custom server variable or something of a similar nature.

    Possibly the ExtensionlessUrlHandler is an issue since it's mentioned in the error. Try commenting out the URL Rewrite rules to see if there is still an issue. That will confirm if the issue is with URL Rewrite or with something else.

    Scott Forsyth
    Microsoft MVP - IIS/ASP.NET
    Dynamicweb North America
    www.dynamicwebusa.com
  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 02:48 PM|doulos2k|LINK

    Thanks for the quick response Scott - I actually read that post yesterday before posting here. I'm certain there's got to be something with the rules. Disabling the rules just creates a 404 condition with no server errors.

    I am using a custom server variable, but I made sure it's also in the Server Variables list (under Manage Server Variables) and I think I did that right because when I first attempted this last week, I was getting specific server variable errors like your blog post mentions. Once I added the server variable, everything seemed to be working... but now it's not.

    Is there anything else that needs to be done for a custom server variable that you're aware of?

  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 03:05 PM|OWScott|LINK

    Your rules seem correct. The only thing that you need for a custom header is to set it at the server level, which you've done.

    How about creating a simple dummy rewrite rule and disabling all of the other ones. Do it from IIS Manager to confirm that the syntax is correct and that no errors occur. That will rule out any issues with URL Rewrite that may have occured with the latest patching and reboot. If it works well then add your rules back one by one to confirm which rule is at fault, and also temporarily remove the custom server variable to rule that out too.

    Scott Forsyth
    Microsoft MVP - IIS/ASP.NET
    Dynamicweb North America
    www.dynamicwebusa.com
  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 03:45 PM|doulos2k|LINK

    So, it turns out it's the Wordpress redirect... the one I thought was the simplest. Disable that and all is well. I set "Stop processing of subsequent rules," but it appears that just having the rule in place at all causes an issue. There's some conflict between these rules.

    If I leave this one enabled and then disable the other two - all is well... and vice versa. I guess I need to figure out why this last rule still interferes even if I check the"Stop processing of subsequent rules" checkbox.

  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 03:55 PM|OWScott|LINK

    That's helpful. Looking at the rules again, they are all rewrites, so all three will be applied to all traffic. The first two function as a reverse proxy and then the 3rd will try to rewrite actual files or folders to index.php on the local server.

    What's the purpose of the 3rd rule if you're already proxying to wordpress on another server?

     

    Scott Forsyth
    Microsoft MVP - IIS/ASP.NET
    Dynamicweb North America
    www.dynamicwebusa.com
  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 03:59 PM|doulos2k|LINK

    I'm only trying to reverse proxy /blog - I still want everything else to process through Wordpress. I figured the order would be good enough.

  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 05, 2013 08:56 PM|OWScott|LINK

    I don't know wordpress enough to know if the third rule is necessary to funnel everything to the single page, but I would suggest a couple things. First, set your first two rules to stop processing subsequent rules. You can do that by adding  stopProcessing="true" to the rule, like: <rule name=...  stopProcessing="true"> ...

    That will probably fix the blog part. After that you can start testing the other pages to get the Wordpress part. By updating the first two rules the third rule will only be run for anything that doesn't start with /blog.

    Scott Forsyth
    Microsoft MVP - IIS/ASP.NET
    Dynamicweb North America
    www.dynamicwebusa.com
  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 06, 2013 09:08 AM|doulos2k|LINK

    That was it. I misunderstood the "stop processing" portion as being handled in a specific order. Marking both the "blog" rules with that allowed the other to fire without problem.

    I greatly appreciate your assistance on this - many thanks!

  • Re: URL Rewrite Throwing 500.50 Error on Reverse Proxy attempt

    Mar 06, 2013 09:48 AM|OWScott|LINK

    Excellent, glad to hear that's working. Thanks for confirming.

    Scott Forsyth
    Microsoft MVP - IIS/ASP.NET
    Dynamicweb North America
    www.dynamicwebusa.com