PHP cURL returns 403 when connected to HTTPS through proxy

Viewed 834

I'm trying to connect to an HTTPS url through a proxy with cURL. I disabled verification since security of the data is no concern, so the error has nothing to do with SSL verification.

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, "https://www.google.com");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); 
curl_setopt($ch, CURLOPT_TIMEOUT, 10); 
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_PROXY, 'proxy.example.com:8080');//working fine when proxy is set to null.
curl_exec($ch); 
print_r(curl_error($ch));

This handle works fine without a proxy, but returns 'received HTTP code (one of 0/403/400) from proxy after CONNECT' when a proxy is set.

Is this how curl works or incurred by the proxy settings? I have tried a few proxies, none has worked.

Thank you.

0 Answers
Related