6.4.0 • Published 2 months ago

proxy-agent v6.4.0

Weekly downloads
3,060,728
License
MIT
Repository
github
Last release
2 months ago

proxy-agent

Maps proxy protocols to http.Agent implementations

This module provides an http.Agent implementation which automatically uses proxy servers based off of the various proxy-related environment variables (HTTP_PROXY, HTTPS_PROXY and NO_PROXY among others).

Which proxy is used for each HTTP request is determined by the proxy-from-env module, so check its documentation for instructions on configuring your environment variables.

An LRU cache is used so that http.Agent instances are transparently re-used for subsequent HTTP requests to the same proxy server.

The currently implemented protocol mappings are listed in the table below:

ProtocolProxy Agent for http requestsProxy Agent for https requestsExample
httphttp-proxy-agenthttps-proxy-agenthttp://proxy-server-over-tcp.com:3128
httpshttp-proxy-agenthttps-proxy-agenthttps://proxy-server-over-tls.com:3129
socks(v5)socks-proxy-agentsocks-proxy-agentsocks://username:password@some-socks-proxy.com:9050 (username & password are optional)
socks5socks-proxy-agentsocks-proxy-agentsocks5://username:password@some-socks-proxy.com:9050 (username & password are optional)
socks4socks-proxy-agentsocks-proxy-agentsocks4://some-socks-proxy.com:9050
pac-*pac-proxy-agentpac-proxy-agentpac+http://www.example.com/proxy.pac

Example

import * as https from 'https';
import { ProxyAgent } from 'proxy-agent';

// The correct proxy `Agent` implementation to use will be determined
// via the `http_proxy` / `https_proxy` / `no_proxy` / etc. env vars
const agent = new ProxyAgent();

// The rest works just like any other normal HTTP request
https.get('https://jsonip.com', { agent }, (res) => {
  console.log(res.statusCode, res.headers);
  res.pipe(process.stdout);
});

API

new ProxyAgent(options?: ProxyAgentOptions)

Creates an http.Agent instance which relies on the various proxy-related environment variables. An LRU cache is used, so the same http.Agent instance will be returned if identical args are passed in.

@stoplight/cli@goodware/winston-cloudwatchcloudstudiocommit-cz-fixeasy-select-rnbrokerapisingpass-myinfo-oidc-helperepi2me-apidiepio.jsproxy-finder-gatewayinsurer-policyapi@jswork/next-proxy-pldown@jswork/next-proxy-spys@jswork/next-proxy-usgatsby-plugin-s3-html-last@sgpinkus/mailgun-jsturing-codefosscord-utilreact-native-printer-brothers@oitq/service-http-server@oitq/plugin-http-serverreact-native-shekhar-bridge-testnightwatch-bench@oiti/documentoscopy-react-nativeinstagram-private-api-gramsterquoc-testlunarjs-discord@infinitebrahmanuniverse/nolb-proxalfalfamale-aws-sso-creds-helper@candidpartners/tf-rulesfirebase-tools-angeloluminos-ui-core@adobe/helix-cli@everything-registry/sub-chunk-2486jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgreact-native-jawwy_sampleot-superagent-proxyomneedia-cinineku.fmmirror2mishiro-coremi-clientnode-red-contrib-awsnoctua-snakenode-ubernode-uber-gmapsnode-ssllabsnightwatch-cr-betanightwatch-sizmeknightwatch-liqidnightwatch-patch-1504node-red-contrib-monsternode-red-contrib-samsung-automation-studio-nodespick-getpm2t-io-agentpmax-gatewaynode-fetch-with-proxynode-lambdanode-dingtalk-robotmeiqia-i18n-extract-climegp-shared-benative-modal-damage-vehiclepubnubpnm-yph-react-native-custom-componentsproject-wajs-dvjawwy_library_newjawy_library_v1gamification-jawwy-libraryframework_test_library_sixdee_new_jawwymtxcmsv3test_lib_module_aargithub-actions.cache-s3react-native-create-video-thumbnailhelix-frontgyumahappypandagcl-attachment-apigenz-native-elementsgriffin-ui-librarygrunt-aws-deploygrunt-aws-lambdagrunt-aws-lambda-forkformer2gamification-integration-newgatsby-plugin-s3-travisbloomgatsby-plugin-s3gaurav-react-native-loophong1-utilshls-downloadhubot-proxy-loaderhubot-fleepgitkm-cligenerator-apisgimmeproxy-requestginue
6.4.0

2 months ago

6.3.0

9 months ago

6.2.1

11 months ago

6.3.1

8 months ago

6.2.2

10 months ago

6.1.0

12 months ago

6.0.0

12 months ago

6.1.2

12 months ago

6.2.0

12 months ago

6.1.1

12 months ago

5.0.0

3 years ago

4.0.1

3 years ago

4.0.0

4 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.3

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.0

7 years ago

2.0.0

9 years ago

1.1.1

9 years ago

1.1.0

10 years ago

1.0.0

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago