proxy-chain
![Build Status](https://travis-ci.org/Apifier/proxy-chain.svg)
Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.
For example, this library is useful if you need to use proxies with authentication
in the headless Chrome web browser, but don't feel like setting up Squid or some other proxy server.
The authentication and proxy chaining configuration is provided in code and can be dynamic.
Run a simple HTTP/HTTPS proxy server
const ProxyChain = require('proxy-chain');
const server = new ProxyChain.Server({ port: 8000 });
server.listen(() => {
console.log(`Proxy server is listening on port ${8000}`);
});
Run a HTTP/HTTPS proxy server with credentials and upstream proxy
const ProxyChain = require('proxy-chain');
const server = new ProxyChain.Server({
port: 8000,
verbose: true,
prepareRequestFunction: ({ request, username, password, hostname, port, isHttp }) => {
return {
requestAuthentication: username !== 'bob' || password !== 'TopSecret',
upstreamProxyUrl: `http://username:password@proxy.example.com:3128`,
};
},
});
server.listen(() => {
console.log(`Proxy server is listening on port ${8000}`);
});