代码之家  ›  专栏  ›  技术社区  ›  Aaron Powell

使用Azure CDN强制HTTPS

  •  18
  • Aaron Powell  · 技术社区  · 7 年前

    我在存储帐户前面使用Azure CDN。我只想通过HTTPS提供服务,所以我在自定义域上设置了HTTPS并创建了URL重写:

    HTTPS rewrite rule

    但问题是,我的URL是这样的: https://the-custom-domain/website/17/index.html

    这个 website/17/index.html 是存储帐户中的根内容,但我不知道为什么它会在文件名之前附加容器路径。静态文件也有重写规则( https://blog.lifeishao.com/2017/05/24/serving-your-static-sites-with-azure-blob-and-cdn )。

    知道URL重写有什么问题吗?

    6 回复  |  直到 6 年前
        1
  •  15
  •   Rune Aamodt    5 年前

    这里有一份MS的官方指南,该指南适用于标准Azure CDN:

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

    总结如下:

    将用户重定向到HTTPS

    • 在CDN配置文件页面上,选择要为其创建规则的端点。
    • 选择规则引擎选项卡。
    • 选择添加规则并输入规则名称。
    • 要标识规则应用于的请求类型,请创建匹配条件:
      • 选择添加条件,然后选择请求协议匹配条件。
      • 选择“等于”作为“运算符”。
      • 选择HTTP作为“值”。
    • 选择要应用于满足匹配条件的请求的操作:
      • 选择添加操作,然后选择URL重定向。
      • 选择“找到”(302)作为“类型”。
      • 对于协议,选择HTTPS。
      • 将所有其他字段留空以使用传入值。
    • 选择保存以保存新规则。现在可以使用该规则。
        2
  •  11
  •   Malt    5 年前

    我正在使用Azure Verizon 保险费 CDN。

    我做了两条规则。规则的顺序很重要。每次测试后,您最多需要等待4小时。

    图像删除索引。html 2继续作为图像3

    enter image description here

    enter image description here

    ================结束第一条规则==================
    enter image description here

    enter image description here

    此处为文本
    1、将HTTP重定向到HTTPs
    规则-->(*)目的地 https://% {主机}/$1

    1. 删除删除索引。html无法100%工作-(
      伪静态
      2、来源((?:[^ \?] /)?)($\\?。 )-目的地->$1指标。html$2
      2、B源((?:[^ \?] /)?[^ \?/.]+)($\\?。 )-目的地->$1/索引。html$2
        3
  •  6
  •   RAL    6 年前

    我正在使用Azure Verizon Premium。

    在这种情况下,您可能希望将http请求重定向到https端点。在这种情况下,必须为每个端点添加一条规则,以实现此行为:

      match condition:
    
        if Request Scheme = HTTP
    
      feature:
    
        Redirect - Code: 301, source: (.*), destination: https://%{host}/$1
    

    此响应位于 docs microsoft

        4
  •  4
  •   Louie Almeda    5 年前

    现在简单多了 enter image description here

    无需在主机名、路径等中输入任何内容。。

    确保在源站设置中同时启用了HTTP和HTTPS enter image description here

    应在10分钟内反射

        5
  •  2
  •   Andrew    5 年前

    我使用以下配置将任何请求重定向到https

    http to https - Azure CDN

    如果

    • 请求架构,HTTP

    特色

    • URL重定向
    • 代码:301
    • 来源:(**)
    • 目的地: https://%{host}/$1
        6
  •  0
  •   bukso    5 年前

    如果您想要简单的1:1 http到https解决方案(没有任何不需要的),则应使用以下规则:

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

    如果

    • 请求架构,HTTP

    特色

    • URL重定向
    • 代码: 301
    • 资料来源: (.*)
    • 目的地: https://%{host}/%{request_uri#/}