another technical blog...technically

Saturday, June 20, 2015

SharePoint 2013 Azure farm accessible from outside part 2: what about friendly URLs

Have you read this? SharePoint 2013 Azure farm accessible from outside
I discovered it doesn't work for friendly urls, it shows hyperlinks targeting site collection, so it's not possible to reach other pages. Moreover you'll get this error if you only create a outbuond rule for URL rewriting because of the gzip compression.
Outbound rewrite rules cannot be applied when the content of the HTTP response is encoded ("gzip").
What you have to do is something like this:
  • Introduce a outbound rule which rewritest some links
  • Introduce rewrite rules for gzip compression
The example below assumes:
  • Local site collection is: http://sitecollection.example.cloud
  • Public azure url is: http://publicsite.example.azure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<configuration>
    <system .webserver="">
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule" stopprocessing="true">
                    <match url="(.*)">
                    <servervariables>
                        <set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="{HTTP_ACCEPT_ENCODING}">
                        <set name="HTTP_ACCEPT_ENCODING" value="">
                    </set></set></servervariables>
                    <action type="Rewrite" url="http://sitecollection.example.cloud/{R:1}">
                </action></match></rule>
            </rules>
 
            <outboundrules rewritebeforecache="true">
                <rule enabled="true" name="RestoreAcceptEncoding" precondition="NeedsRestoringAcceptEncoding">
                    <match pattern="^(.*)" servervariable="HTTP_ACCEPT_ENCODING">
                    <action type="Rewrite" value="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}">
                </action></match></rule>
                <rule enabled="true" name="ReverseProxyOutboundRule" precondition="ResponseIsHtml">
                    <match filterbytags="A, Img" pattern="^http(s)?://sitecollection.example.cloud/(.*)">
                    <action type="Rewrite" value="http{R:1}://publicsite.example.azure/{R:2}">
                </action></match></rule>
 
                <preconditions>
                    <precondition name="NeedsRestoringAcceptEncoding">
                        <add input="{HTTP_X_ORIGINAL_ACCEPT_ENCODING}" pattern=".+">
                    </add></precondition>
                    <precondition name="ResponseIsHtml">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html">
                    </add></precondition>
                </preconditions>
          </outboundrules>         
        </rewrite>
    </system>
</configuration>
And that's all... for now!
Share:

Related Posts:

0 commenti:

Post a Comment

Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?