A 502 error occurs when you use phpcurl to request an https url. PHP version: 5.6.7Nginx version: 1.8.0 code: {code ...} php-fpm log: {code ...} A 502 error occurs when you use php curl to request an https url.
PHP version: 5.6.7
Nginx version: 1.8.0
The Code is as follows:
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://www.baidu.com');curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_TIMEOUT, 10);curl_exec($ch);
Php-fpm log:
[28-Jun-2015 04:04:20] NOTICE: [pool www] child 21701 started[28-Jun-2015 04:07:33] WARNING: [pool www] child 21692 exited on signal 11 (SIGSEGV) after 222.256700 seconds from start[28-Jun-2015 04:07:33] NOTICE: [pool www] child 21735 started
Reply content:
A 502 error occurs when you use php curl to request an https url.
PHP version: 5.6.7
Nginx version: 1.8.0
The Code is as follows:
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, 'https://www.baidu.com');curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_TIMEOUT, 10);curl_exec($ch);
Php-fpm log:
[28-Jun-2015 04:04:20] NOTICE: [pool www] child 21701 started[28-Jun-2015 04:07:33] WARNING: [pool www] child 21692 exited on signal 11 (SIGSEGV) after 222.256700 seconds from start[28-Jun-2015 04:07:33] NOTICE: [pool www] child 21735 started
The code is correct...
I encountered the same problem all morning ~~
Re-compile PHP and disable the SQLITE module.
It looks ridiculous, but it does.
I have also encountered such a strange problem before. Your PHP compilation may be in conflict with a module, re-Minimal compilation or try another machine.
// $ Return = curl_exec ($ ch );
$ Return = curl_exec ($ ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/600.3.18 (KHTML, like Gecko) version/8.0.3 Safari/600.3.18 "); the simulated browser does not report 502, but why ~ ----------------------------------------- After two or three hours, google Baidu has no fruit, and does not want to reload the curl-V to support both ssl and https; I tried to reinstall curl because I used php56 installed by brew. brew uninstall curl; brew install curl -- with-openssl; I fixed a bug after restarting PHP ~ Summary curl itself does not support openssl
For https requests, set CURLOPT_SSL_VERIFYPEER to true.
You do not need to add CURLOPT_SSL_VERIFYHOST. Try it!
Does openssl come with the system? Some images have compatibility issues with openssl and curl, which will be reflected in php https requests. Reload openssl and try again.
PHP5.4 and PHP7 RC2 of Ubuntu 14.04 self-compiled, with SQLite extension, run the landlord's code, there is no problem. The dependent curl library islibcurl3:amd64 7.35.0-1ubuntu2.5
:
dpkg -S /usr/lib/x86_64-linux-gnu/libcurl.so.4.3.0
Same problem api https cannot access MAC brew to install php
I am running OK
For HTTPS problems, add fastcgi_param HTTPS on after fastcgi_pass. The problem should be solved.