proxy

Summary

Pass a string to specify an HTTP proxy, or an array to specifydifferent 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 ofhost names that should not be proxied to.

Note

Guzzle will automatically populate this value with your environment'sNO_PROXY environment variable. However, when providing a proxyrequest option, it is up to your to provide the no value parsed fromthe 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, "password@192.168.16.1:10&#34"">http://username:password@192.168.16.1:10".