在我的https网站上,如何在没有证书的情况下显示来自网站的图像?
我拥有以下示例域:
我拥有www .example.com 的证书,但不拥有静态 .example.com 的证书.
在我的www.example.com域上,您可以使用http S://www.example.com 注册SSL服务
在注册表(www..)上,我想显示来自我的CDN的图像,该图像位于http:// static .example.com上,但不拥有该子域的证书.
在https://www.example.com注册表 - 我正在使用AJAX从http://动态提取图像static.example.com.使用AJAX时,Web浏览器似乎根本不显示非SSL图像.但是,如果该图像位于http S://www.example.com域(与注册表单相同),则图像将通过AJAX显示.
出于架构和设计原因,我想将这些图像保存在我的CDN(static.example.com)上,而无需购买证书.
有谁知道我如何通过我的http S://.xample域上的非SSL子域通过AJAX显示这些图像?
提前致谢.
小智 16
你可以自己创建ssl代理.
通过此脚本运行所有图像.只需创建一个文件并将此PHP代码放入其中.使用curl或file_get_contents回显内容.
因此,如果您想要调用安全映像,请将其称为:
https://mysecureserver.com/path_to_this_script/?url=[base64 encoded image link]
<?php
$strFile = base64_decode(@$_GET['url']);
$strFileExt = end(explode('.' , $strFile));
if($strFileExt == 'jpg' or $strFileExt == 'jpeg'){
header('Content-Type: image/jpeg');
}elseif($strFileExt == 'png'){
header('Content-Type: image/png');
}elseif($strFileExt == 'gif'){
header('Content-Type: image/gif');
}else{
die('not supported');
}
if($strFile != ''){
$cache_ends = 60*60*24*365;
header("Pragma: public");
header("Cache-Control: maxage=". $cache_ends);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache_ends).' GMT');
//... [and get the content using curl or file_get_contents and echo it out ]
}
exit;
?>
Run Code Online (Sandbox Code Playgroud)
就像您要包含 https 图像一样:
<img src="http://www.google.com/intl/en_ALL/images/logo.gif" />
Run Code Online (Sandbox Code Playgroud)
不过,某些浏览器可能会向用户抱怨您正在为安全页面加载不安全的资源。你对此无能为力。
| 归档时间: |
|
| 查看次数: |
39308 次 |
| 最近记录: |