gpt4 book ai didi

php - 需要通过 https 加载 http js 和 css - 出现 mix_content 错误

转载 作者:可可西里 更新时间:2023-10-31 23:45:09 27 4
gpt4 key购买 nike

我正在尝试在 https 网站的 iframe 中加载 http 网站。我知道它会给我 js 和 css 的 mixed_content 错误,所以为了解决 mixed_content 我正在使用如下代理:

$url = "http://www.myweb.com";
$PROXY_HOST = "47.52.24.117"; // Proxy server address
$PROXY_PORT = "80"; // Proxy server port
$PROXY_USER = ""; // Username
$PROXY_PASS = ""; // Password
// Username and Password are required only if your proxy server needs basic authentication

$auth = base64_encode("$PROXY_USER:$PROXY_PASS");
stream_context_set_default(
array(
'http' => array(
'method'=>"GET",
'proxy' => "tcp://$PROXY_HOST:$PROXY_PORT",
'request_fulluri' => true,
'header' => "Proxy-Authorization: Basic $auth"
// Remove the 'header' option if proxy authentication is not required
)
)
);
$res = file_get_contents($url);
echo $res;

但我仍然遇到 js 和 css 的 mixed_content 错误。 (图像和 html 内容在 https 下加载正常)。

最佳答案

这主要是评论 - 但评论框中的空间有限。

首先,您没有提到您使用的是什么浏览器。 MSIE 可能会针对一些非混合内容的内容抛出此错误。如果您使用的是 MSIE,您可以尝试使用不同的浏览器,看看问题是否出自 Microsoft 的怪癖,或者错误是否真的出在您的代码中。

当您说“如下所示”时,我希望这不是您用来从远程站点检索内容的代码,因为您已经在此处对 URL 进行了硬编码。我会说这是通过您没有告诉我们的前端 Controller 、mod_rewrite 或 404 处理程序处理的,您已验证代理脚本正确翻译了 URL/所提供的内容是您期望什么并在测试之间清除缓存....

您是否检查过您正在下载的脚本和 CSS 不包含指向 http://URL 的 URL?

您向我们展示的代码还有一个问题,即它不检查/传递 mimetype。

关于php - 需要通过 https 加载 http js 和 css - 出现 mix_content 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45461552/

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