Enabling reverse proxy in Sitecore on Azure PaaS and gotchas

In Sitecore or any .Net application, you can easily achieve Reverse Proxy with the help of Url Rewrite and Application Request Routing (ARR) as mentioned in https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing.

There are some nice blogs and answers available to achieve same in Sitecore.

Recently, we were required to achieve exact same thing. But the tweak was our instance is on Azure PaaS. So, It’s clear from the configuration in Sitecore’s perspective. But one can have questions like Do we need to install ARR on WebApp? How do we enable Reverse Proxy setting on ARR without IIS access? We were having the same access. Let’s answer these questions.

Do we need to install ARR on WebApp?

No. We do not require to install ARR additionally as site extension.
site extensions

Azure PaaS provides great scaling options. One of the popular scaling strategy is Scale Out to multiple instance. If you want to know more on Sitecore and Azure scale out, check this: https://pratiksatikunvar.wordpress.com/2019/06/02/troubleshooting-sitecore-on-azure-paas-part-3/
So, to achieve sticky behavior and to make sure next request for a user goes to the same instance, Azure uses ARR in the background. So, you do not need to worry about installing ARR separately irrespective of ARRAffinity is on or off on your WebApp.

How do we enable Reverse Proxy setting on ARR without IIS access?

We can enable proxy in IIS as mentioned below:
image5

But as we do not have dedicated IIS in Azure PaaS, question is Do we need to enable proxy in WebApp? Yes. By default proxy is not enabled. And we can enable that as mentioned below:

ApplicationHost.xdt

You need to create this file and upload to Site directory of your WebApp.

2019-07-01 23_39_47-Diagnostic Console
This file will override applicationhost.config, taking advantage of a feature in Azure, called Azure Site Extensions, that provides a mechanism to apply transforms to applicationhost.config using XDT transforms.

And finally, you need to restart the WebApp for changes to take effect.

Gotchas

Our rewrite rule was looking something like below:

<rule name=”Blog” enabled=”true” stopProcessing=”true” >
<match url=”^blogs/(.*)$” />
<action type=”Rewrite” url=”https://Blog_Site_Url/{R:1}” />
</rule>

So, this rule was working fine for home page. But as soon as you access inner pages, it was redirecting to pagenotfound which we had implemented. So, we were changing rules multiple times and also we were first checking the rule with Redirect type.

So, after sometime, even if we changed our rule to type Rewrite, it was redirecting to the blog site. We tried to restart the WebApp but there was no luck.

One can also configure disk caching with ARR as mentioned in https://docs.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/configure-and-enable-disk-cache-in-application-request-routing. But we were not sure as we do not have access to IIS. So, we decided to disable the caching to check weather it was caching issue or not.

To disable the disk caching. You can update your applicationhost.xdt as mentioned:

And after the restarting WebApp it should have been resolved in case of caching issue. But it wasn’t working still. At the end it was issue with the site we were trying to rewrite. So, this way you can manage settings for which you don’t have directly access.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s