如何在HTTPS连接上显示非SSL图像? [英] How to display non-SSL images on HTTPS connection?
问题描述
在我的https网站上,如何在没有证书的情况下显示来自网站的图像?
On my https web site, how can I display images from a web site without a certificate?
我拥有以下示例域:
- http:// www .example.com
- http:// 静态 .example.com(用于我的CDN)
- http://www.example.com
- http://static.example.com (used for my CDN)
我拥有 www .example.com但不适用于静态 .example.com。
I own a certificate for www.example.com but not for static.example.com.
在我的www.example.com域名,您可以注册使用http S ://www.example.com
On my www.example.com domain, you can register for the service over SSL using httpS://www.example.com
在SSL上提供服务在注册表单(www。)上,我想显示图片来自我的CDN,它位于http:// static .example.com上,但没有该子域的证书。
On the registration form (www.), I want to display images from my CDN which is on http://static.example.com but don't own a certificate for that subdomain.
关于https:// www.example.com注册表 - 我正在使用AJAX从http:// static.example.com动态提取图片。使用AJAX时,Web浏览器似乎根本不显示非SSL图像。但是,如果该图片位于http S ://www.example.com域(与注册表单相同),则图片将通过AJAX显示。
On the https://www.example.com registration form - I'm using AJAX to dynamically pull over the image from http://static.example.com. It seems that the web browser does not display non-SSL images at all when using AJAX. However, if that image were located on the httpS://www.example.com domain (the same as the registration form), the image will display via AJAX.
对于建筑和工程设计原因,我想将这些图像保存在我的CDN(static.example.com)上而无需购买证书。
For architecture & design reasons, I would like to keep those images on my CDN (static.example.com) without having to purchase a certificate.
有谁知道我怎么能显示这些来自我的http S :// .xex域名的非SSL子域名中的AJAX图片?
Does anyone know how I can display these images via AJAX from my non-SSL subdomain on my httpS://www.example domain?
提前致谢。
推荐答案
你可以自己创建ssl代理。
you can make your own ssl proxy.
运行所有图片这个脚本。
只需创建一个文件并将此PHP代码放入其中。使用 curl
或 file_get_contents
来回显内容。
Run all the images through this script.
Just make a file and put this PHP code inside. Use curl
or file_get_contents
to echo out the content.
因此,如果你想调用安全图像,你可以这样称呼:
So if you want to call the secure image, you call it like this:
https://mysecureserver.com/path_to_this_script/?url = [base64编码图像链接]
<?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;
?>
这篇关于如何在HTTPS连接上显示非SSL图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!