如何将HTTPS IP重定向到域

问题描述 投票:3回答:3

我有一个在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

asp.net redirect iis https url-redirection
3个回答
3
投票

尝试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/


1
投票

鉴于HTTPS私有IP永远不会有效(你无法获得有效的证书),我认为你已经到了这里,因为你有从http://192.168.0.3https://192.168.0.3的全局重定向。只需修复重定向,就可以直接从http://192.168.0.3https://example.com


-1
投票

您可以做的是在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>
© www.soinside.com 2019 - 2024. All rights reserved.