1

我在 localhost 上有两个本地服务器(配置为 nginx 代理后面的 docker 容器),我想在服务器 A 中使用 CURL 来使用服务器 B 的 API。它们都使用带有自签名证书的 SSL(也已经配置)。

    curl_setopt($request, CURLOPT_CAINFO, __DIR__ . '/../' . getenv('SERVER_B_CA_CERT'));
    curl_setopt($request, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
    curl_setopt($request, CURLOPT_SSL_VERIFYPEER, getenv('CURL_SSL_VERIFYPEER'));
    curl_setopt($request, CURLOPT_SSL_VERIFYHOST, getenv('CURL_SSL_VERIFYHOST'));

CURLOPT_SSL_VERIFYHOST 和 CURLOPT_SSL_VERIFYPEER 都设置为 false。

我从 PHP 的 curl 库中收到“连接被拒绝”(curl 错误代码 7)消息。我的容器之间没有防火墙,我的 nginx 代理似乎配置正确。服务器已启动并正在侦听,因为我已经能够使用 Web 浏览器和 curl 客户端连接到它。

有任何想法吗?

编辑:

php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "*   Trying 127.0.0.1..."
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* TCP_NODELAY set"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* connect to 127.0.0.1 port 443 failed: Connection refused"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "*   Trying ::1..."
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* TCP_NODELAY set"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* Immediate connect fail for ::1: Cannot assign requested address"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "*   Trying ::1..."
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* TCP_NODELAY set"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* Immediate connect fail for ::1: Cannot assign requested address"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* Failed to connect to server-b.local.com port 443: Connection refused"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "* Closing connection 0"
php_1       | [05-Mar-2019 22:49:40] WARNING: [pool www] child 66 said into stderr: "NOTICE: PHP message: CURL ERROR = Failed to connect to server-b.local.com port 443: Connection refused, CODE = 7"
4

0 回答 0