我有一个在IIS 8.5上托管的asp.net网站,我使用以下规则将所有流量重定向到HTTPS:
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{SERVER_PORT_SECURE}" pattern="^0$" />
</conditions>
<action type="Redirect" url="https://example.com{REQUEST_URI}" redirectType="Temporary" />
</rule>
当用户使用https://192.168.0.3
访问该站点时,这不起作用
Your connection is not private
Attackers might be trying to steal your information from 192.168.0.3 (for example, passwords, messages, or credit cards). Learn more
NET::ERR_CERT_COMMON_NAME_INVALID
安装的SSL是针对域example.com的,似乎请求没有到达IIS,所以我没有任何控制权....我无法控制用户强制他们使用域名网址。
如何将https:/192.168.0.3
重定向到https://example.com
?
尝试SSL保护本地IP URL将始终以证书错误AFAIK结束
阅读本文以了解更多信息:https://security.stackexchange.com/questions/103524/lets-encrypt-for-intranet-websites
编辑:我不太了解IIS,但在这件事上发现了这一点,可能它会帮助你解决这个问题:https://blogs.msdn.microsoft.com/robert_mcmurray/2013/11/15/how-to-trust-the-iis-express-self-signed-certificate/
鉴于HTTPS私有IP永远不会有效(你无法获得有效的证书),我认为你已经到了这里,因为你有从http://192.168.0.3
到https://192.168.0.3
的全局重定向。只需修复重定向,就可以直接从http://192.168.0.3
到https://example.com
。
您可以做的是在IIS中创建另一个网站并将IP地址绑定到它。然后在该网站上创建一个Default.aspx
页面,并重定向到正确的域。
<%@ Page Language="C#" %>
<%
Response.Redirect("https://example.com");
%>
或者只是一个带有url重写的web.config
文件
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url="(.*)" />
<action type="Redirect" redirectType="Permanent" url="https://example.com" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>