【问题标题】:Force https on Azure Websites - web.config - Laravel 4在 Azure 网站上强制使用 https - web.config - Laravel 4
【发布时间】:2016-01-31 05:26:21
【问题描述】:

我正在尝试对所有流量强制使用 https。

我已经尝试了许多在互联网和微软自己的网站上找到的 web.config 规则,但似乎没有一个按应有的方式重定向到 https。

我不知道是否发生了某些变化,导致所有这些规则都无效,但无论如何它都不起作用。

这是我目前检查的内容:

 <rule name="Force HTTPS" enabled="true" stopProcessing="true">
    <match url="(.*)" ignoreCase="false" />
       <conditions>
          <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
       </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />

 <rule name="Redirect to https">
  <match url="(.*)"/>
  <conditions>
    <add input="{HTTPS}" pattern="Off"/>
    <add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
  </conditions>
  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule>

      <rule name="Force HTTPS" enabled="true">
      <match url="(.*)" ignoreCase="false" />
      <conditions>
        <add input="{HTTPS}" pattern="off" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>

来自: https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure-ssl-certificate/

有什么想法吗?

提前致谢!

【问题讨论】:

  • 您可以在 DNS 端执行此操作。一种选择是在云耀斑上设置页面规则。

标签: azure iis ssl laravel-4


【解决方案1】:

好的 - 只是在这上面浪费了 2 个小时,但答案非常微妙。

我在 azure 网站上运行 laravel4,要让它工作,它需要两个 web.config 文件:一个在“site/wwwroot/public”文件夹中,一个在“site/wwwroot”文件夹中。

我的问题是我忘记了这一点,只修改了公用文件夹中的那个。

解决方案是将规则添加到站点/wwwroot 中的 web.config 文件中,而不是站点/wwwroot/public 中。

我没有测试我之前提到的所有规则,但使用了 microsoft 建议的规则并且它有效。

祝你好运。

<rule name="Force HTTPS" enabled="true">
    <match url="(.*)" ignoreCase="false" />
        <conditions>
            <add input="{HTTPS}" pattern="off" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>

【讨论】:

    猜你喜欢
    • 2020-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-08
    • 1970-01-01
    • 2021-08-20
    • 1970-01-01
    相关资源
    最近更新 更多