Socket
Socket
Sign inDemoInstall

proxying-agent

Package Overview
Dependencies
0
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    proxying-agent

Node HTTP/HTTPS Forward Proxy Agent


Version published
Maintainers
1
Install size
30.3 kB
Created

Readme

Source

Node HTTP/HTTPS Forward Proxy Agent

This a Node http agent capable of forward proxying HTTP/HTTPS requests.

It supports the following:

  • Connect to a proxy with either HTTP or HTTPS
  • Proxying to a remote server using SSL tunneling (via the http CONNECT method)
  • Authenticate with a proxy with Basic authentication
  • Authenticate with a proxy with NTLM authentication (beta)

The agent inherits directly from the http.Agent Node object so it benefits from all the socket handling goodies that come with it.

Installation

npm install proxying-agent

Usage

The following options are supported:

  • proxy - Specifies the proxy url. The supported format is http[s]://[auth@]host:port where auth is the authentication information in the form of username:password. The authentication information can also be in the form of a Base64 encoded user:password, e.g. http://dXNlcm5hbWU6cGFzc3dvcmQ=@proxy.example.com:8080
  • tunnel - If true then the proxy will become a tunnel to the server. This should usually be true only if the target server protocol is https
  • tlsOptions - TLS connection options to use when the target server protocol is https. See http://nodejs.org/api/tls.html#tls_tls_connect_options_callback for a list of available options.
  • authType - Proxy authentication type. Possible values are basic and ntlm (default is basic).
  • ntlm - (beta) applicable only if authType is ntlm. Supported fields:
    • domain (required) - the NTLM domain
    • workstation (optional) - the local machine hostname (os.hostname() is not specified)

HTTP Server

  var proxying = require('proxying-agent');
  var proxyingOptions = {
    proxy: 'http://proxy.example.com:8080'
  };
  var proxyingAgent = new proxying.ProxyingAgent(proxyingOptions);
  var req = http.request({
    host: 'example.com',
    port: 80,
    agent: proxyingAgent
  });

HTTPS Server

  var proxying = require('proxying-agent');
  var proxyingOptions = {
    proxy: 'http://proxy.example.com:8080',
    tunnel: true
  };
  var proxyingAgent = new proxying.ProxyingAgent(proxyingOptions);
  var req = https.request({
    host: 'example.com',
    port: 443,
    agent: proxyingAgent
  });

Basic Authentication

  var proxying = require('proxying-agent');
  var proxyingOptions = {
    proxy: 'http://username:password@proxy.example.com:8080',
    tunnel: true
  };
  var proxyingAgent = new proxying.ProxyingAgent(proxyingOptions);
  var req = https.request({
    host: 'example.com',
    port: 443,
    agent: proxyingAgent
  });

NTLM Authentication

When authenticating using NTLM it is important to delay sending the request data until the socket is assigned to the request. Failing to do so will result in the socket being prematurely closed, preventing the NTLM handshake from completing.

  var proxying = require('proxying-agent');
  var proxyingOptions = {
    proxy: 'http://username:password@proxy.example.com:8080',
    tunnel: true,
    authType: 'ntlm',
    ntlm: {
      domain: 'MYDOMAIN'
    }
  };
  var proxyingAgent = new proxying.ProxyingAgent(proxyingOptions);
  var req = https.request({
    host: 'example.com',
    port: 443,
    agent: proxyingAgent
  });

  req.on('socket', function(socket) {
    req.write('DATA');
    req.end();
  });

References

Copyright 2013-2014 Capriza. Code released under the MIT license

Keywords

FAQs

Last updated on 03 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc