7

Is there a way that for certain URLs (like /blog/*) to load the content from other server, i.e implementing a reverse proxy?

We were able to do this with a normal site (non Sitecore) but when Sitecore is present it seems that the URL rules from our web.config or http://www.helicontech.com/isapi_rewrite/ are ignored and the rules from Sitecore take precedence and when accessing the URL instead of getting the content from the other site (i.e. reverse proxy working) we get the Sitecore 404 page.

Is there a way to do this with Sitecore? Maybe set thing up in a way that for certain URL patterns Sitecore is bypassed and the web.config and/or Helicon module rules are executed instead (which have support for reverse proxy)?

5
  • 4
    Did you try appending the urls to the IgnoreUrlPrefixes setting in Sitecore config?
    – jammykam
    Commented Jan 3, 2017 at 8:58
  • Not yet, I'll ask the devs if they tried this. Thanks.
    – daniels
    Commented Jan 3, 2017 at 8:59
  • Check the module load order and make sure the UrlRewrite is executed before any Sitecore modules. Commented Jan 3, 2017 at 20:57
  • @daniels is the answer working for you what I provided? would be nice to have a feedback on that. Commented Jan 6, 2018 at 9:50
  • We end up using CloudFlare to act as both CDN (caching) and reverse proxy
    – daniels
    Commented Jan 6, 2018 at 13:32

1 Answer 1

9

We faced the same issue about a month ago. You can use the following rewrite rule.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Blog rewrite" enabled="true" >
          <match url="^blog/(.*)$" />
          <action type="Rewrite" url="http://your.other.domain/{R:0}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

We also had to ignore the route for the blog because of MVC route resolving.

using System.Web.Routing;
using Sitecore.Mvc.Pipelines.Loader;
using Sitecore.Pipelines;


namespace MyProject
{
    public class RegisterRoutes : InitializeRoutes
    {
        public override void Process(PipelineArgs args)
        {
            RouteTable.Routes.Ignore("blog/{*pathInfo}");
        }
    }
}

Related config:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="MyProject.RegisterRoutes, MyProject" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc']" />
      </initialize>
    </pipelines>
  </sitecore>
</configuration>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.