混合内容:Chrome在我的网站上阻止了<img/>,但没有

时间:2017-02-20 12:05:46

标签: html mixed-content

我有一个HTTPS站点,可以从HTTP RSS源加载内容。在尝试加载图片时,Chrome / Firefox会使用以下消息阻止他们:

Mixed Content: The page at 'mysite.com/index.php' was loaded over HTTPS, but requested an insecure image 'http://www.example.com/2017021411050.jpg'. This request has been blocked; **the content must be served over HTTPS**.

但是,如果我在Feeldy中加载相同的Feed,我可以看到所有图像,尽管Feedly的网站也是通过HTTPS加载的。在Feedly案例中,浏览器只显示警告:

The page at 'https://feedly.com/i/subscription/feed/http://www.example.com/rss.php' was loaded over HTTPS, but requested an insecure image 'http://www.example.com/2017021411050.jpg'. **This content should also be served over HTTPS**.

为什么Feedly可以绕过混合内容块,并且在我遇到阻止时只会收到警告?

2 个答案:

答案 0 :(得分:0)

Firefox和Chrome都是安全的浏览器,但我不确定Feedly到底是什么。 Firefox和Chrome会阻止它们,因为他们认为在HTTP网站中加载HTTP图像并不安全,但Feedly并不关心所以他认为只是发出警告就足够了。 但我知道解决这个问题的解决方案 例如,你有这个URL

http://otherdomain.com/image.jpg

这是一个HTTP,然后你改变它

https://example.com/imageserver?url= //here put your image url

这个技巧会让浏览器认为你是通过HTTPS URL加载图像,如下所示

https://example.com/imageserver?url=http://otherdomain.com/image.jpg&hash=abcdeafad

答案 1 :(得分:-1)

解析RSS源时,您还要检索图片网址。

假设图片网址为http://externalsite.com/someimage.jpg

您将此网址重写为https://example.com/image?url=http://externalsite.com/someimage.jpg&hash=1234567

现在浏览器总是通过https发出请求,你就摆脱了问题。