npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

proxying-agent

v2.4.0

Published

Node HTTP/HTTPS Forward Proxy Agent

Downloads

59,942

Readme

Node HTTP/HTTPS Forward Proxy Agent

This is 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)
  • Set a global agent for all http and https requests

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

create(options, target)

Returns a new agent configured correctly to proxy to the specified target.

  • options - (string|object) proxy url string or object with the following options:
    • 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://[email protected]:8080. if the username for NTLM needs to be in the domain\username format, specify domain%5Cusername instead
    • 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)
  • target - the target url that the agent is to proxy

globalize(options)

Set a global agent to forward all http and https requests through the specified proxy. Make sure to call this method before invoking any other http request. After globalize is invoked, all http and https requests will automatically tunnel through the proxy.

  • options - See create method
  require('proxying-agent').globalize('http://proxy.example.com:8080');

HTTP Server

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

HTTPS Server

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

Basic Authentication

  var proxyingAgent = require('proxying-agent').create('http://username:[email protected]:8080', 'https://example.com');
  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 proxyOptions = {
    proxy: 'http://username:[email protected]:8080',
    authType: 'ntlm',
    ntlm: {
      domain: 'MYDOMAIN'
    }
  };
  var proxyingAgent = require('proxying-agent').create(proxyOptions, 'https://example.com');
  var req = https.request({
    host: 'example.com',
    port: 443,
    agent: proxyingAgent
  });

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

References

  • NTLM code was forked from https://github.com/SamDecrock/node-http-ntlm.git
  • NTLM Authentication Scheme for HTTP - http://www.innovation.ch/personal/ronald/ntlm.html

Copyright and License

Copyright 2016 Capriza. Code released under the MIT license