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 a regular socket or SSL/TLS socket
- 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 (experimental). Depends on
node-ntlm
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
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
});
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 only be true
if the target server protocol is httpsntlm
- (experimental) connect to the proxy using NTLM authentication. ntlm
is expected to contain the
following fields:
hostname
- the local machine hostnamedomain
- the NTLM domainusername
- the NTLM usernamepassword
- the NTLM password