Reverse proxy from IIS 8.5 to an azure website

I have a VM in azure with IIS, I’m already running a website in that VM let’s say mysite.com not I’d like to have my blog in a directory within the website, the blog is a WordPress site hosted separately in another azure website like http://siteblog.azurewebsites.net

reverse proxy

Read More

I’ve done a reverse proxy with two rules in the IIS, the issue is with the outbound rule, I get the following error:

Outbound rewrite rules cannot be applied when the content of the HTTP
response is encoded (“gzip”).

Searching on google I found this article and two questions 1,2 all of them practically apply almost the same approach.

According to the article, I have to add a key to the windows registry which as far I know isn’t possible.

On the machine running the web site, from the command line run: reg
add HKEY_LOCAL_MACHINESOFTWAREMicrosoftInetStpRewrite /v
LogRewrittenUrlEnabled /t REG_DWORD /d 0 You may need to follow this
up with an iisreset

my rules in the IIS web.config:

<rewrite>
    <outboundRules>
        <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" stopProcessing="false">
            <match filterByTags="A, Area, Base, Form, Img, Link" pattern="^http(s)?://mseblog.azurewebsites.net/(.*)" />
            <action type="Rewrite" value="http{R:1}://mysite.com/{R:2}" />
        </rule>

        <preConditions>
            <preCondition name="ResponseIsHtml1">
                <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
            </preCondition>
        </preConditions>
    </outboundRules>
    <rules>
        <rule name="ReverseProxyInboundRule1" stopProcessing="true">
            <match url="(.*)" />
            <conditions>
                <add input="{CACHE_URL}" pattern="^(https?)://" />
            </conditions>
            <action type="Rewrite" url="{C:1}://siteblog.azurewebsites.net/{R:1}" logRewrittenUrl="false" />
        </rule>
    </rules>
</rewrite>

Questions:

  • How can I fix the error?
  • Any other approach besides using URL rewriting or reverse proxy?

Related posts

Leave a Reply