HTTPS到HTTP JSONP请求

Sam*_*cía 11 javascript ajax https jsonp cross-domain

我在从HTTPS站点向HTTP站点发送JSONP请求时遇到问题.

我有一个(非本地)测试环境而不是https(有效证书),我可以成功运行所有这些跨站点/"交叉协议"请求(有警告,但没有错误).

Google Chrome Javascript控制台输出:

The page at https://my.test.environment/ ran insecure content from http://non.secure.site/service?jsonCallback=jsonp1331132928704
Run Code Online (Sandbox Code Playgroud)

但是,在制作中,(在Google App Engine上,appspot子域名)Google Chrome会阻止所有等待用户确认的请求.

Google Chrome Javascript控制台输出(特别注意[已阻止]文字):

[blocked] The page at https://production.appspot.com/ ran insecure content from http://non.secure.site/service?jsonCallback=jsonp1331132928704
Run Code Online (Sandbox Code Playgroud)

我知道我在做什么并不安全,但这项服务是由第三方提供的,到目前为止还没有SSL通信.我真的很困惑,因为我不明白为什么在测试环境中工作(有警告)而不是appspot(Google App Engine).

我试图调查标题但没有成功.

测试环境标题:

Connection:Keep-Alive
Content-Encoding:gzip
Content-Language:es
Content-Length:2524
Content-Type:text/html;charset=utf-8
Date:Wed, 07 Mar 2012 15:48:30 GMT
Keep-Alive:timeout=15, max=100
Set-Cookie: cookie_info...
Vary:Accept-Encoding
Run Code Online (Sandbox Code Playgroud)

APPSpot标题:

access-control-allow-credentials:false
access-control-allow-origin:*
cache-control:no-cache, must-revalidate
content-encoding:gzip
content-length:47890
content-type:text/html; charset=utf-8
date:Wed, 07 Mar 2012 14:52:02 GMT
expires:Fri, 01 Jan 1990 00:00:00 GMT
pragma:no-cache
server:Google Frontend
set-cookie: coookie_info....
status:200 OK
vary:Accept-Encoding
version:HTTP/1.1
Run Code Online (Sandbox Code Playgroud)

我不知道为什么这会影响测试环境,而且Google Chrome上的APPSpot也阻止了同样的方法.

有什么想法吗?

Sha*_*mal 1

Apache 代理将代表您向端点发出请求。您甚至可以向服务(json、xml、图像、post、put、delete 等)发出非 jsonp 请求,因为浏览器认为它正在向同一域发出请求。

您的 non.secure.site vhost 文件将包含类似的内容

ProxyRequests Off
ProxyPreserveHost On 
<Proxy *>
    Allow from all
</Proxy>
ProxyPass /appspot https://production.appspot.com/
ProxyPassReverse /appspot https://production.appspot.com/
Run Code Online (Sandbox Code Playgroud)

设置完成后,您只需调用该服务即可...

http://non.secure.site/appspot/service?jsonCallback=jsonp1331132928704
Run Code Online (Sandbox Code Playgroud)

谷歌代理通行证了解更多信息

https://serverfault.com/questions/429404/help-me-understand-how-to-use-proxypass