6.5.0 • Published 6 months ago

proxy-agent v6.5.0

Weekly downloads
3,060,728
License
MIT
Repository
github
Last release
6 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.

@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@everything-registry/sub-chunk-2486jawwy-sdkjawwy_gamification_releasereact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgreact-native-jawwy_samplegriffin-ui-librarysynthara-musicszm-deliverysynopsys-sig-nodetest-cdktest-library-123test-haptik-libwinston-cloudwatch-logsvv-yapi-to-typescriptwifi_configuration_packagexemphimxen-apiteik_lib_1teapackage-tatespoorman297superagent-proxysuperagent-proxy-ieesupaitelescopysteamhourapitest-synopsys-sig-nodetest-zeo-collectsuscipitincidunttf-rulesthe-dukevision-camera-plugin-face-detectorvision-camera-base64-resizedvantiq-reactvsc-custom-css-clivue-dev-clone@discue/firebase-tools@cloudinary/media-management@coco-platform/init@codefresh-io/cf-git-providers@crawly/request-client@cristiand391/sf-plugin-api@crysmi/aws-azure-login@cs6/react-native-test-native-view-library@con-test/react-native-concent-common@damruravihara/react-native-testing-package@databricks/sql@bluecube/gateway@rsrini/jdeps-search@pown/request@praella/localisationist@primarybid/aws-azure-login@runbook/node-fetchegg-gen-clijpom-i18njrennsoh88-react-native-scroll-indicatorjianghu-initjesh-calculationjnf-accesscontrol-rnttljordy-frijters-test-libjovo-cli-deploy-lambdaintelephenseiot-jobs-agentkf-clikeekijanai-serverkeekijanai-server-commonkeekijanai-server-corekhaled-salem-custom-components
6.5.0

6 months ago

6.4.0

1 year ago

6.3.0

2 years ago

6.2.1

2 years ago

6.3.1

2 years ago

6.2.2

2 years ago

6.1.0

2 years ago

6.0.0

2 years ago

6.1.2

2 years ago

6.2.0

2 years ago

6.1.1

2 years ago

5.0.0

4 years ago

4.0.1

4 years ago

4.0.0

5 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.3

7 years ago

3.0.1

7 years ago

3.0.0

7 years ago

2.3.1

7 years ago

2.3.0

7 years ago

2.2.0

7 years ago

2.1.0

8 years ago

2.0.0

10 years ago

1.1.1

10 years ago

1.1.0

11 years ago

1.0.0

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago