I'm using Guzzle 6.0.2 ( Also tried with 5.3.0 ) in Laravel environment.
For testing purposes I created Controller with index method to test Guzzle POST request to other web server.
My method:
<?php
public function index()
{
$uri = 'https://payment.my-url.com/gw/testing';
// $uri = 'http://pay.my-url.com/gw/testing';
$client = new \GuzzleHttp\Client();
$resource = $client->post($uri, [
'json' => ['foo' => 'bar'],
'headers' => [
'Accept' => '*/*; q=0.5, application/xml',
'Content-Type' => 'application/json; charset=utf-8',
'User-Agent' => 'Client/1.0',
],
]);
$statusCode = $resource->getStatusCode();
}
When I try to access URL with this method, i receive 502 Bad Gateway from my server, but it only occours if I'm trying to send to HTTPS $uri. If I send to HTTP ( non secure ) uri then my request goes to foreign web server and there I can dump POST data array.
I have nginx 1.8.0 and PHP 5.6.9 on OSX environment.
I also tried to add extra configuration to guzzle client but this does not make any difference:
'curl' => [
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
],
'verify' => false,
Why my web server gives me 502 bad Gateway when I try to send POST to HTTPS uri with GuzzleHTTP component ?
https://payment.my-url.com/gw/testing
you succeed. I'm trying to figure out if remote server responding https requests correctly. – Ugur