CodeIgniter 4.4.0 added a proxy option to CURLRequest. Supply a proxy URL in the request’s options array:

$client = service('curlrequest');
$response = $client->request('GET', 'https://api.example/', [
    'proxy' => 'http://proxy.example:8080',
    'connect_timeout' => 5,
    'timeout' => 30,
]);

proxy accepts one URL string. A Requests-style http/https mapping is a different format. Check the installed CodeIgniter version if this option is unavailable.

CURLRequest sets CURLOPT_PROXY and enables CURLOPT_HTTPPROXYTUNNEL for the option. The HTTP intermediary must therefore allow CONNECT to the intended target.

Use the listener’s actual scheme in the proxy URL and keep the API endpoint in the request URL. For permitted public-API requests, the HTTP proxy list supplies candidates for the HTTP proxy URL; check that the node permits CONNECT to the actual target. Handle the returned response and failures through the application’s existing call path.

Ũhoro ũhĩtĩte