Ever been asked to set up a Reverse Proxy to allow a particular URL on your website to fetch its content from a site somewhere else? It's not an uncommon requirement, but it seems to cause some configuration challenges too. Having been drafted in to solve some issues with just such a setup recently, here's a quick description of the stuff I need to remember next time I get this job:
The key fields you need to configure are:
(.*)
which just matches anything. Chances are you have some sort of base url you need to match for this sort of reverse proxy – so you might have a rule like
the-url-you-want-to-reverse-proxy/(.*)
to match your prefix, and squirrel away everything else for use later. (Also, note that this process matches just the URL's path by default – you don't need to account for domain names)https://MyOtherDomain.com/SomePath/{R:1}
to take whatever was left at the end of your Pattern and put add it to your rewritten domain.But if you have more complex rewriting requirements, your rules will look more complex too. If you do, you'll likely end up filling in extra conditions in the details of your rule:
There are two ways you can go about this. First, you can write some code to customise routing, and explicitly tell the routing engine to ignore the path(s) you want to reverse-proxy for. Depending on the version of Sitecore, you might add some routing config to the initialise pipeline to do this:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("some-reverse-proxied-path/{*pathInfo}"); }
(See documentation for details, or this Stack Exchange thread.)
Or alternatively you can patch Sitecore's pre-existing setting for what URLs it should ignore. While this isn't one of the easiest settings to patch (Because by default it's just a big string – though there are approaches you can use to make this easier if you want), it is probably the quickest way to make Sitecore ignore a url, and doesn't involve deploying code:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <settings> <setting name="IgnoreUrlPrefixes" value="/the-url-you-want-to-reverse-proxy|/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing|/sitecore/service/xdb/disabled.aspx" /> </settings> </sitecore> </configuration>
OTB it's just a pipe-separated list of URL prefixes, without domain names – so you can just stick your required URL onto the beginning...
And once you've sorted those three settings you should find that your reverse-proxy urls start to work.
↑ Back to top