2013-06-28 28 views
0

我们无法通过代理使用php和curl进行https请求。我们试图从PHP到https://google.com发出一个简单的curl请求,并且我们收到消息'请求无法处理。代理或网关服务器收到的无效响应'。对http:/google.com的相同请求正常工作。我们也能够从curl命令行成功调用任何https网址。下面是我们的卷毛请求。代理不需要登录,我们已经在PHP中安装了openssl。任何答复表示赞赏。无法通过代理使用,PHP和卷曲进行https请求

$url='https://google.com'; 
$handle = curl_init(); 
curl_setopt($handle, CURLOPT_URL, $url); 
curl_setopt($handle, CURLOPT_PROXY, 'some proxy'); 
curl_setopt($handle, CURLOPT_PROXYPORT, 80); 
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false); 
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($handle, CURLOPT_VERBOSE, TRUE); 
$data = curl_exec($handle); 
+0

您的代理服务器是否需要凭据? –

+0

不需要任何凭证。 – user1470056

+0

好的,那你应该把'CURLOPT_FOLLOWLOCATION'设置为'true'。 –

回答

0

尝试改变:

curl_setopt($handle, CURLOPT_PROXYPORT, 80); 

到:

curl_setopt($handle, CURLOPT_PROXYPORT, 443); 

由于https流量是通过端口443

+0

通过将端口更改为443进行测试,得到相同的502错误请求无法处理。代理或网关服务器收到的响应无效。 – user1470056

0

curl_setopt($卷曲,CURLOPT_SSL_VERIFYPEER,0);

它适用于我。