title: PHP cURL code 502 from proxy after CONNECT, but it work for other website
body: <p>I am trying to connect to an HTTP site (eg <a href="http://www.http2demo.io/" rel="nofollow noreferrer">http://www.http2demo.io/</a>) using a proxy. But i don't know why it work for a website like google (https) but not for a http website</p>
  
  <pre><code>$url = 'https://google.com'; // **If I replace google.com by http://www.http2demo.io/ or any http website it send me a 502 error**
  $proxyauth = 'Flexxa:XWIUHY';
  $proxy = '45.77.161.17';
  $proxyPort = '505';
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  //proxy suport
  curl_setopt($ch, CURLOPT_PROXY, $proxy);
  curl_setopt($ch, CURLOPT_PROXYPORT, $proxyPort);
  curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
  curl_setopt($ch, CURLOPT_PROXYTYPE, 'HTTP');
  curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
  //https
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/27.0.1453.94 Safari/537.36");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 100);
  
  $output = curl_exec($ch);   
  
  if(curl_exec($ch) === false)
  {
      echo 'Curl error: ' . curl_error($ch);
  }
  else
  {
      echo 'Operation completed without any errors';
  }
  
  echo $output;
  
  curl_close($ch);
  ?&gt;
  </code></pre>
  
  <p>The first one work but not the other</p>