none
Rules for HTTP to HTTPS redirect, and default document for Azure CDN Premium Verizon

    Question

  • Hi,

    I have been using Premium Verizon CDN in Azure, and got HTTPS working (thanks to the MS support team!)

    Right now, I'm having some trouble with the Rules Engine for the following tasks:

    1. Redirect HTTP to HTTPS

       Ex: http://www.example.com/* -> 301 redirect -> https://www.example.com/*

    2. Load default index.html

       Ex: https://www.example.com should return https://example_cdn.azureedge.net/index.html

    #1 seems to be working, but it's redirecting to a wrong link, like so:

       Wrong: http://www.example.com -> 301 redirect -> https://www.example.com/origin_blob_path/index.html

       Correct: http://www.example.com -> 301 redirect -> https://www.example.com/ (returns index.html)

    Can someone help me with the exact rules for this?

    Normally I would hammer at this, but the 4 hour refresh time is killing me, and there is very sparse documentation on how to do this.

    I will give the rule XML on request.

    Thanks,

    David


    Thursday, March 28, 2019 10:10 AM

All replies

  • Hi David, 

    Can you share me the XML, I can try this in my subscription and check if I can get this working. 

    Also, I see that you mentioned, it appends /origin blob path to the URL. Do you have the storage blob as the origin to the CDN? 

    Why can't you try static web page in Storage blob where you don't need to specify the index.html?

    Regards, 

    Msrini


    Thursday, March 28, 2019 10:42 AM
    Moderator
  • Hi Msrini,

    Here's the XML:

    <rules schema-version="2" rulesetversion="30" rulesetid="xxxxx4" xmlns="http://www.whitecdn.com/schemas/rules/2.0/rulesSchema.xsd">
      <rule id="xxxxxx6" platform="http-large" status="active" version="8" custid="xxxA1">
        <description>force https</description>
        <!--If-->
        <match.request-scheme value="http">
          <feature.url-redirect code="301" pattern="/80xxxx1/my-domain-static/(.*)" value="https://www.my-domain.com/$1" />
        </match.request-scheme>
      </rule>
      <rule id="xxxxxx3" platform="http-large" status="active" version="2" custid="xxxA1">
        <description>force https 2</description>
        <!--If-->
        <match.request-scheme value="http">
          <feature.url-redirect code="301" pattern="/00xxxx1/(.*)" value="https://www.my-domain.com/$1" />
        </match.request-scheme>
      </rule>
      <rule id="xxxxxx0" platform="http-large" status="active" version="3" custid="xxxx1">
        <description>index.html</description>
        <!--If-->
        <match.always>
          <feature.url-user-rewrite pattern="/80xxxx1/my-domain-static/$" value="/80xxxx1/my-domain-static/index.html" />
        </match.always>
      </rule>
      <rule id="xxxxxx4" platform="http-large" status="active" version="1" custid="xxxA1">
        <description>index.html 2</description>
        <!--If-->
        <match.always>
          <feature.url-user-rewrite pattern="/80xxxx1/my-domain-static/((?:[^\?]*/)?)($|\?.*)" value="/80xxxx1/my-domain-static/$1index.html$2" />
          <feature.url-user-rewrite pattern="/80xxxx1/my-domain-static/((?:[^\?]*/)?[^\?/.]+)($|\?.*)" value="/80xxxx1/my-domain-static/$1.html$2" />
        </match.always>
      </rule>
      <rule id="xxxxxx5" platform="http-large" status="active" version="2" custid="xxxA1">
        <description>Max-age 1 year</description>
        <!--If-->
        <match.always>
          <feature.set-response-header action="set" key="Cache-Control" value="31536000" />
        </match.always>
      </rule>
    </rules>

    As you may surmise, I'm just going by trial and error here.

    As to your second question, I tried static web page in storage blob, but it didn't fit our needs.

    Thanks,

    David


    Thursday, March 28, 2019 2:02 PM
  • Hi Msrini,

    I've been experimenting using a test endpoint in the meantime, no luck. I think the worst thing about this is that there's so little feedback on how is it not working. Are there any logs or similar that I can take a look at?

    Also, the 4 hour wait just to make sure I'm not getting any stale results is really really annoying.

    Thanks,

    David


    Tuesday, April 2, 2019 5:35 AM
  • Hi Ian, 

    I don't think there are logs that are exposed to users. 

    Can you check this thread?

    https://stackoverflow.com/questions/50807457/static-hosting-reactjs-app-on-azure-blob-storage-with-azure-cdn

    Regards, 

    Msrini

    Tuesday, April 2, 2019 5:48 AM
    Moderator