I'm trying to use a forward proxy server (Apache Traffic Server or Squid) on my local machine, as a local HTTP cache for my cURL calls.
I've set up the proxy using:
curl_setopt($ch, CURLOPT_PROXY, 'http://localhost:8080');
When I query an HTTP website, cURL performs a standard HTTP GET
proxy request, which can be cached properly:
GET http://example.com/ HTTP/1.1
However, when querying an HTTPs website, cURL performs a CONNECT
instead, effectively using the proxy as a TCP tunnel, and preventing it from caching the response:
CONNECT example.com:80 HTTP/1.1
Is there a way to force cURL to perform a GET
request even for HTTPs websites?
I can understand the rationale behind using a TCP tunnel for HTTPs requests over an HTTP proxy for security, but because my proxy server is on localhost, I don't care using an insecure HTTP connection to the proxy, and would like cURL to perform a GET
request:
GET https://example.com/ HTTP/1.1
I tried using:
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false);
But this didn't change anything.
curl --socks5 127.0.0.1:8889 https://www.example.com/ -v
If you are using HTTP proxy:curl -x http://PROXY_HOST:PROXY_PORT https://www.example.com/ -v
– Lydoncurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
option? ;) – LydonCURLOPT_SSL_VERIFYPEER
tofalse
just prevents cURL from verifying the validity of the SSL certificate, which is unrelated. – Aliaalias