19

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?

AshokPeddakotla
  • 1,010
  • 7
  • 18
Aaron Powell
  • 24,927
  • 18
  • 98
  • 150

6 Answers6

17

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.
Rune Aamodt
  • 2,551
  • 2
  • 23
  • 27
  • 1
    I've created a complete tutorial for setting up your static website on Azure, which includes this and more, here: https://the.aamodt.family/rune/2020/01/08/tutorial-azure-website.html – Rune Aamodt Jan 08 '20 at 10:44
  • This answer is gold, I was about to get the premiun service to get this thing to work. The only thing I am courius about is if this affects your SEO or AdRank on google? – Gerardo Jaramillo Jan 08 '20 at 18:00
  • Good question, unfortunately I'm not familiar with how this affects SEO. – Rune Aamodt Jan 08 '20 at 18:27
  • 1
    thanks! I guess I need to do more research, I heard some time ago that 302 was not good for SEO, but investigating recently it seems that google not always take it as a bad thing. Your solution works awesome for what I need! thank you anyway. – Gerardo Jaramillo Jan 09 '20 at 16:59
  • well at first it didn't work Had to change, **"For Type, select Found (302)"** -> **"Permanent redirect(308)"** Voila, it worked. – Poornamith Feb 18 '20 at 17:46
11

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
Malt
  • 28,965
  • 9
  • 65
  • 105
Valentin Petkov
  • 1,570
  • 18
  • 23
  • This looks to only be available via Verizon Premium: **HTTP to HTTPS redirection** You can redirect HTTP traffic to HTTPS. Doing so requires the use of the Azure CDN premium offering from Verizon [https://learn.microsoft.com/en-us/azure/storage/blobs/storage-https-custom-domain-cdn](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-https-custom-domain-cdn) – Simon Jun 25 '19 at 10:40
6

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

RAL
  • 61
  • 1
  • 2
5

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

Louie Almeda
  • 5,366
  • 30
  • 38
  • Yes, but this is the microsoft standard cdn. Verizon premium cdn has still the same problem – bukso Feb 04 '20 at 12:00
2

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
Andrew
  • 18,680
  • 13
  • 103
  • 118
Alok Singh
  • 21
  • 1
  • can you tell me what is wrong wiith my config? https://drive.google.com/file/d/1ADN1O-oEhZ7CYcMNRZ-GYNx_OCmrEMDz/view?usp=sharing – jayasurya_j Nov 08 '19 at 06:48
0

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#/}
bukso
  • 1,108
  • 12
  • 23