Guzzle's proxy option accepts a full endpoint URL. Set it on the request when only that operation should use the IP you selected.

<?php
require __DIR__ . '/vendor/autoload.php';

$client = new GuzzleHttp\Client();
$response = $client->request('GET', 'https://example.com/', [
    'proxy' => 'http://203.0.113.10:8080',
    'connect_timeout' => 5,
    'timeout' => 15,
    'http_errors' => false,
]);

echo $response->getStatusCode(), PHP_EOL;
echo (string) $response->getBody();

The example assumes Guzzle 7 is installed through Composer. Replace the documentation address with an actual HTTP proxy from your provider or the HTTP proxy list. Keep the destination in the request URL: the proxy is an intermediary, not the resource being downloaded.

Here http_errors is false so an HTTP error response remains available for inspection. Connection failures still throw transfer exceptions. An HTTPS tunnel rejected during setup can therefore fail before you receive an ordinary website response object.

Check the handler when connection limits behave differently

Guzzle can use different HTTP handlers. Its documentation says connect_timeout is supported by the built-in cURL handler. A custom handler or an environment without PHP cURL is not necessarily equivalent. Check the handler used by the application before assuming that a copied timeout option is taking effect.

The overall timeout is also worth setting. Free list entries can stop replying between checks, and the default is not a useful deadline for a request that must finish promptly.

Using a proxy map

A map lets you choose routes by destination scheme and provide explicit bypass hosts:

'proxy' => [
    'http' => 'http://203.0.113.10:8080',
    'https' => 'http://203.0.113.10:8080',
    'no' => [],
],

Use this array in place of the string option. The HTTPS key selects HTTPS destinations; its HTTP value still describes the proxy listener. A different listener protocol requires different endpoint configuration.

When you supply the proxy request option yourself, Guzzle expects you to supply any intended no values rather than automatically copying them from NO_PROXY. An empty list is useful for an isolated proxy test. In an application with deliberate bypass rules, preserve those rules explicitly instead.

Tënë sô zo