How to Redirect HTTP Traffic to HTTPS in Azure CDN

How to Redirect HTTP Traffic to HTTPS in Azure CDN

This post describes how to use the Standard rules engine for Azure Content Delivery Network (Azure CDN) in order to set up a rule that forces redirecting HTTP traffic to HTTPS.

I have a static website deployed to a cloud storage account in Azure. For this website, I used a custom domain endpoint enforcing HTTPS traffic only. Which caused a problem for users who tried to browse the website by typing HTTP in the URL.

How To Enable HTTPS Redirection in Azure CDN

Azure CDN has a rules engine that allows you to redirect traffic, this can be used to replace all HTTP traffic to HTTPS.

  • Navigate to the CDN endpoint and on the left-hand navigation select Rules Engine, then create a new rule.
  • Add a condition where the Request Protocol is HTTP.
  • Add a URL Redirect action and set the Type to 302 and the Protocol to HTTPS, leaving all the other fields blank. By leaving these other fields blank it maintains the URL path and any query parameters, only the protocol will change.

Enable HTTPS Redirection in Azure CDN

After saving, it can take up to 10 minutes to see the rule in action. But then any HTTP traffic will be redirected successfully to HTTPS.

1 Comments

  1. https gained popularity since Google started considering them. It is good to know how to enable https redirection in azure.

    ReplyDelete
Previous Post Next Post