Level 53
You should simply do it like this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ($_ENV['API_ENDPOINT_NGINX_IP'] . '/' . $url));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Prevents usage of a cached version of the URL
curl_setopt($ch, CURLOPT_FRESH_CONNECT, TRUE);
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
dd($statusCode, $response);
There is no point in mixing PHP curl setopt and then running a curl command via console.
note that curl_getinfo($ch, CURLINFO_HTTP_CODE) has to come after curl_exec($ch) or it returns 0