proxy

Summary

Pass a string to specify an HTTP proxy, or an array to specify different proxies for different protocols.

Types

  • string
  • array

Default

None

Constant

GuzzleHttp\RequestOptions::PROXY

Pass a string to specify a proxy for all protocols.

  1. $client->request('GET', '/', ['proxy' => 'tcp://localhost:8125']);

Pass an associative array to specify HTTP proxies for specific URI schemes (i.e., “http”, “https”). Provide a no key value pair to provide a list of host names that should not be proxied to.

Note

Guzzle will automatically populate this value with your environment’s NO_PROXY environment variable. However, when providing a proxy request option, it is up to you to provide the no value parsed from the NO_PROXY environment variable (e.g., explode(',', getenv('NO_PROXY'))).

  1. $client->request('GET', '/', [
  2. 'proxy' => [
  3. 'http' => 'tcp://localhost:8125', // Use this proxy with "http"
  4. 'https' => 'tcp://localhost:9124', // Use this proxy with "https",
  5. 'no' => ['.mit.edu', 'foo.com'] // Don't use a proxy with these
  6. ]
  7. ]);

Note

You can provide proxy URLs that contain a scheme, username, and password. For example, "http://username:password@192.168.16.1:10".