Home  >  Article  >  Backend Development  >  curl数据提交 在nginx中报错

curl数据提交 在nginx中报错

WBOY
WBOYOriginal
2016-06-13 11:47:55812browse

curl数据提交 在nginx中出错
请问: 
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(); <br />curl_setopt($ch, CURLOPT_URL,'http://192.168.247.138:8181/a2.php'); <br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); <br />curl_setopt($ch, CURLOPT_TIMEOUT, 3);<br />$data = curl_exec($ch); <br />var_dump($data);<br />curl_close($ch); <br />

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