Home >Backend Development >PHP Tutorial >curl数据提交 在nginx中出错

curl数据提交 在nginx中出错

WBOY
WBOYOriginal
2016-06-23 14:39:591018browse

请问: 
curl方法数据提交,在apache服务器运行,没有任何问题。 
在nginx服务中,curl_exec($ch)执行结果为false,且只有等到timeout后,该php才会停止执行,否则一直处于刷新状态。 

nginx.conf该怎么配置,才能解决此问题。 谢谢 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL,'http://192.168.247.138:8181/a2.php'); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
$data = curl_exec($ch); 
curl_close($ch); 
var_dump($data);
?>


回复讨论(解决方案)

$ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'http://192.168.247.138:8181/a2.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 3);$data = curl_exec($ch); var_dump($data);curl_close($ch); 

看到这么一篇文章,但是不知道该如何设置,请大家指点。 
"苦闷中,想起nginx的一个参数proxy_buffering,它的含义是:nginx不是立即转发收到的请求,而是等buffer满之后再转发。默认是on。把它改成off,使用curl请求nginx抓取xuri就行了,数据是完整的,没有超时。"
http://gcoder.diandian.com/post/2011-05-19/17355206

不知道是否是这个问题,请问我该如何测试: http://www.ioutlier.com/nginx-proxy-buffer-works/

不知道LZ这个问题是怎么解决的!我也遇到了同样的问题!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn