获得 SSL,现在所有请求的文件都被阻止(混合内容)
Got SSL, now all requested files are blocked (mixed content)
我有一些客户在他们的页面上使用 HTML,这是我提供的。 HTML 链接到我服务器上的文件(JS、CSS、图像等)。
我给他们的例子:
<link type="text/css" rel="stylesheet" href="http://www.example.org/this.css" />
我刚刚获得 SSL,所以我的站点现在是 https。然而,当我从我的服务器请求文件时,我给他们的服务器上的 HTML 仍然是 http。
因此,他们收到混合内容警告并且内容被阻止。像这样:
混合内容:位于“https://www.example.org/' was loaded over HTTPS, but requested an insecure stylesheet 'http://www.example.org/file.css”的页面。此请求已被阻止;内容必须通过 HTTPS 提供。
我不能让我所有的客户将他们所有页面上的所有链接都更改为 "https",从而阻止 warning/blockage。那将是一场噩梦。
我的主机是 GoDaddy。我的服务器是Windows服务器,IIS:7.0,ASP.Net运行时版本:4.0/4.5.
我如何通过 web.config 解决这个问题?我当前的规则是:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
我想要发生的是允许所有外部 http 请求到我的 https 服务器。
谢谢!
您可以为网站提供 Content-Security-Policy: upgrade-insecure-requests
header。
也可以使用 meta
元素指定 upgrade-insecure-requests
CSP 指令:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
The HTTP Content-Security-Policy (CSP) upgrade-insecure-requests
directive instructs user agents to treat all of a site's insecure URLs (those served over HTTP) as though they have been replaced with secure URLs (those served over HTTPS). This directive is intended for web sites with large numbers of insecure legacy URLs that need to be rewritten.
upgrade-insecure-requests
指令 is supported in all current browsers。
顺便说一句,“'https://www.example.org/'
处的页面是通过 HTTPS 加载的,但请求了一个不安全的样式表 'http://www.example.org/file.css'
” 消息不是任何人都会看到的只需在他们自己的网站的 HTML 中添加一个 <link…href="http://www.example.org/this.css" />
元素即可。他们获得该消息的唯一方法是直接导航到 https://www.example.org/
.
我有一些客户在他们的页面上使用 HTML,这是我提供的。 HTML 链接到我服务器上的文件(JS、CSS、图像等)。
我给他们的例子:
<link type="text/css" rel="stylesheet" href="http://www.example.org/this.css" />
我刚刚获得 SSL,所以我的站点现在是 https。然而,当我从我的服务器请求文件时,我给他们的服务器上的 HTML 仍然是 http。
因此,他们收到混合内容警告并且内容被阻止。像这样:
混合内容:位于“https://www.example.org/' was loaded over HTTPS, but requested an insecure stylesheet 'http://www.example.org/file.css”的页面。此请求已被阻止;内容必须通过 HTTPS 提供。
我不能让我所有的客户将他们所有页面上的所有链接都更改为 "https",从而阻止 warning/blockage。那将是一场噩梦。
我的主机是 GoDaddy。我的服务器是Windows服务器,IIS:7.0,ASP.Net运行时版本:4.0/4.5.
我如何通过 web.config 解决这个问题?我当前的规则是:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
我想要发生的是允许所有外部 http 请求到我的 https 服务器。
谢谢!
您可以为网站提供 Content-Security-Policy: upgrade-insecure-requests
header。
也可以使用 meta
元素指定 upgrade-insecure-requests
CSP 指令:
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
The HTTP Content-Security-Policy (CSP)
upgrade-insecure-requests
directive instructs user agents to treat all of a site's insecure URLs (those served over HTTP) as though they have been replaced with secure URLs (those served over HTTPS). This directive is intended for web sites with large numbers of insecure legacy URLs that need to be rewritten.
upgrade-insecure-requests
指令 is supported in all current browsers。
顺便说一句,“'https://www.example.org/'
处的页面是通过 HTTPS 加载的,但请求了一个不安全的样式表 'http://www.example.org/file.css'
” 消息不是任何人都会看到的只需在他们自己的网站的 HTML 中添加一个 <link…href="http://www.example.org/this.css" />
元素即可。他们获得该消息的唯一方法是直接导航到 https://www.example.org/
.