gpt4 book ai didi

asp.net-mvc-4 - Azure 云服务将 http 重定向到 https 不起作用(在许多链接上尝试过答案)

转载 作者:行者123 更新时间:2023-12-04 23:23:11 24 4
gpt4 key购买 nike

我正在尝试执行将流量从 http 重定向/重写为 https 的“简单”任务,我在 CloudService 中有一个端点,该端点已正确配置为 SSL。

我已经尝试了许多 IIS 重写规则,如下所示,但没有一个起作用。我还尝试直接通过远程桌面在 IIS 8 服务器上设置规则,但这也不起作用。

当我在 Azure web.config 文件中输入任何标记时,重写标记下方有一条蓝线,并显示一条消息,说明该标记在 <system.webServer> 下无效。 :

<system.webServer>
...
<rewrite>
<rules>
<rule name="RedirectToHTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>

</system.webServer>

非常感谢任何建议。

最佳答案

为了使这些规则发挥作用,您必须配置两者端点 - HTTP HTTPS!!

如果您没有在端口 80 上配置纯 HTTP 端点,您的服务器将永远不会受到 Internet 流量的影响,因此重写规则永远不会触发。因此,当您尝试通过纯 HTTP 打开域时,您会遇到超时。当您没有为其定义端点时,根本就没有进程在端口 80 上监听。

关于asp.net-mvc-4 - Azure 云服务将 http 重定向到 https 不起作用(在许多链接上尝试过答案),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18868678/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com