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.
- $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 proxy
request option, it is up to your to provide the no
value parsed fromthe NO_PROXY
environment variable(e.g., explode(',', getenv('NO_PROXY'))
).
- $client->request('GET', '/', [
- 'proxy' => [
- 'http' => 'tcp://localhost:8125', // Use this proxy with "http"
- 'https' => 'tcp://localhost:9124', // Use this proxy with "https",
- 'no' => ['.mit.edu', 'foo.com'] // Don't use a proxy with these
- ]
- ]);
Note
You can provide proxy URLs that contain a scheme, username, and password.For example, "password@192.168.16.1:10""">http://username:password@192.168.16.1:10"
.