代码之家  ›  专栏  ›  技术社区  ›  Kannaiyan

使用Azure的http到https端点

  •  0
  • Kannaiyan  · 技术社区  · 7 年前

    使用AWS,我可以使用API网关和CloudFront将http转换为https端点,并获得如下URL,

    https://4z9giyi2c1.execute-api.us-west-2.amazonaws.com/test/petstore/pets?type=fish

    我怎样才能用Azure实现同样的功能?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Zhaph - Ben Duguid    7 年前

    Azure Front Door 这是您需要的选项。

    此服务提供一个组合的Web应用程序防火墙、流量管理器(用于路由)和CDN一体式服务。更重要的是,与其他纯CDN Azure产品不同,它允许SSL终止:

    您可以将路由规则配置为仅接受http或https中的一种,或同时接受两者,然后路由详细信息允许您指定是将请求作为仅https、仅http(您想要的)还是“匹配请求”传递:

    Routing options within Front Door

        2
  •  0
  •   George Chen    7 年前

    这有一个开源扩展:

    1. Development Tools 酒吧,你可以找到 Extensions 选项卡,然后单击添加。

    2. 在延期之前 Redirect HTTP to HTTPS Security Settings: HTTPS Redirect w/KeepAlive Support, Headers incl HSTS, CSP, and More. "Medium strength". .

    enter image description here

    1. 添加扩展并重新启动web。

    有关此扩展的更多详细信息, check the source code on github applicationhost.xdt

              <rewrite xdt:Transform="InsertIfMissing">
                    <rules xdt:Transform="InsertIfMissing" lockElements="clear">
                        <rule name="redirect HTTP to HTTPS" enabled="true" stopProcessing="true" lockItem="true" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)">
                            <match url="(.*)" />
                            <conditions>
                                <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                                <add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
                                <add input="{HTTP_USER_AGENT}" pattern="Initialization" negate="true" ignoreCase="false" />
                                <add input="{HTTP_USER_AGENT}" pattern="SiteWarmup" negate="true" ignoreCase="false" />
                                <add input="{HTTP_USER_AGENT}" pattern="AlwaysOn" negate="true" ignoreCase="false" />
                            </conditions>
                            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
                        </rule>
                    </rules>
                </rewrite>
    
        3
  •  0
  •   Community Mohan Dere    6 年前

    更新

    云锋 是AWS CND,它是一个分布式服务器网络,可以高效地向用户交付web内容。CDN将缓存内容存储在边缘服务器上靠近最终用户的存在点(POP)位置,以最大限度地减少延迟。Azure的CDN是 Azure Content Delivery Network (CDN)

    如果您的目标是为您的应用程序强制实施HTTPS,那么CDN可能不是最佳的可用选项,因为CDN用于向全球分散的客户提供低删除率和高可用性的静态内容。虽然,您可以将HTTPS与CDN一起使用,但这将导致使用CDN服务的成本。

    所以,若您的主要目标是使用HTTPs,那个么下面的过程就是为了 将SSL绑定到自定义域名以强制HTTPS通信 与您的网站。

    1. 创建了一个应用程序服务应用程序

    2. 将自定义DNS名称映射到您的应用服务应用

    3. 拥有用于签署SSL证书请求的私钥

    在Azure门户中,访问要为其添加SSL证书的webapp。然后点击 SSL设置 在应用程序的左侧导航中。然后点击 上传证书 将其添加到web应用程序中。

    添加绑定

    强制使用HTTPS :-

    您可以将所有HTTP请求重定向到HTTPS端口。 在应用程序页面的左侧导航中,选择 . 然后,在 仅限HTTPS ,选择On。

    有关更多信息和完整教程,请访问 Tutorial: Bind an existing custom SSL certificate to Azure App Service

    但是,如果您打算将CDN服务与安全HTTPs一起使用 下面是使用Azure CDN启用连接的过程 使用SSL的自定义域。

    1. 在Azure门户中,浏览到您的 天青CDN Microsoft的标准、Akamai的Azure CDN标准、Verizon的Azure CDN标准或Verizon profile的Azure CDN Premium。
    2. CDN端点 ,选择包含自定义域的端点。
    3. 在名单上 自定义域
    4. 在下面 ,选择CDN托管。

    有关更多信息,请参阅 Configure HTTPS on an Azure CDN custom domain

    如果您只想在Azure CDN中将HTTP流量重定向到HTTPs,则只需使用Azure CDN规则引擎创建URL重定向规则。有关更多信息,请参阅 HTTP-to-HTTPS redirection