Aaron Powell
Aaron Powell

Reputation: 25099

Forcing HTTPS with Azure CDN

I’m using Azure CDN in front of a Storage Account. I’m wanting to serve everything via HTTPS only, so I’ve setup HTTPS on the custom domain and created a URL rewrite:

HTTPS rewrite rule

But the problem is that I end up at a URL like this: https://the-custom-domain/website/17/index.html

The website/17/index.html is the root content within the Storage Account, but I don’t know why it’s appending the container path before the filename. There’s also rewrite rule for static files (https://blog.lifeishao.com/2017/05/24/serving-your-static-sites-with-azure-blob-and-cdn).

Any idea what’s wrong with the URL rewrite?

Upvotes: 19

Views: 11298

Answers (6)

bukso
bukso

Reputation: 1366

If you want simple 1:1 http to https solution (without any unwanted) you should use following rule:

https://%{host}/%{request_uri#/}

IF

  • Request Schema, HTTP

Feature

  • URL Redirect
  • Code: 301
  • Source: (.*)
  • Destination: https://%{host}/%{request_uri#/}

Upvotes: 0

Louie Almeda
Louie Almeda

Reputation: 5612

It's a lot simpler now enter image description here

No need to enter anything to the hostname, path etc..

Make sure that you have turned on both HTTP and HTTPS in the Origin Settings enter image description here

It should reflect within 10minutes

Upvotes: 5

Rune Aamodt
Rune Aamodt

Reputation: 2611

There is an official guide from MS here, which works with standard Azure CDN:

https://learn.microsoft.com/en-us/azure/cdn/cdn-standard-rules-engine

Summary below:

Redirect users to HTTPS

  • On the CDN profile page, select the endpoint you want to create rules for.
  • Select the Rules Engine tab.
  • Select Add rule and enter a rule name.
  • To identify the type of requests the rule applies to, create a match condition:
    • Select Add condition, and then select the Request protocol match condition.
    • For Operator, select Equals.
    • For Value, select HTTP.
  • Select the action to apply to the requests that satisfy the match condition:
    • Select Add action, and then select URL redirect.
    • For Type, select Found (302).
    • For Protocol, select HTTPS.
    • Leave all other fields blank to use incoming values.
  • Select Save to save the new rule. The rule is now available to use.

Upvotes: 18

Valentin Petkov
Valentin Petkov

Reputation: 1648

I am using Azure Verizon Premium CDN.

I did two rules. The order of the rules matter. You will need to wait up to 4 hours after each test.

image remove index.html 2 continue as image 3

enter image description here

enter image description here

=============== END FIRST RULE ==================
enter image description here

enter image description here

here as text
1. redirect HTTP to HTTPs
rule--> (.*) destination https://%{host}/$1

  1. remove remove index.html did not work 100% ;-(
    URL Rewrite
    2.A Source ((?:[^\?]/)?)($|\?.) -Destination -> $1index.html$2
    2.B Source ((?:[^\?]/)?[^\?/.]+)($|\?.) -Destination - > $1/index.html$2

Upvotes: 11

Alok Singh
Alok Singh

Reputation: 21

I am using below configuration for redirecting any request to https

http to https - Azure CDN

IF

  • Request Schema, HTTP

Feature

  • URL Redirect
  • Code: 301
  • Source: (.*)
  • Destination: https://%{host}/$1

Upvotes: 2

RAL
RAL

Reputation: 61

I'm using Azure Verizon Premium.

In this case you might want to redirect your http requests to your https endpoint. In this case you must add one rule for each endpoint you want this behavior:

  match condition:

    if Request Scheme = HTTP

  feature:

    Redirect - Code: 301, source: (.*), destination: https://%{host}/$1

This response was found at docs microsoft

Upvotes: 6

Related Questions