【发布时间】:2018-01-09 17:18:43
【问题描述】:
我正在尝试在 https 网站的 iframe 中加载 http 网站。我知道它会给我 js 和 css 的混合内容错误,所以要解决混合内容,我使用如下代理:
$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 的混合内容错误。 (图片和 html 内容在 https 下可以正常加载)。
【问题讨论】:
标签: php proxy file-get-contents