node-http-proxy/examples/http/ntlm-authentication.js
Adam Roderick ecdfff408f Update ntlm-authentication.js
missing bracket
2016-04-14 16:21:39 -05:00

27 lines
729 B
JavaScript

var httpProxy = require('http-proxy');
var Agent = require('agentkeepalive');
var agent = new Agent({
maxSockets: 100,
keepAlive: true,
maxFreeSockets: 10,
keepAliveMsecs:1000,
timeout: 60000,
keepAliveTimeout: 30000 // free socket keepalive for 30 seconds
});
var proxy = httpProxy.createProxy({ target: 'http://whatever.com', agent: agent });
//
// Modify headers of the request before it gets sent
// So that we handle the NLTM authentication request
//
proxy.on('proxyRes', function (proxyRes) {
var key = 'www-authenticate';
proxyRes.headers[key] = proxyRes.headers[key] && proxyRes.headers[key].split(',');
});
require('http').createServer(function (req, res) {
proxy.web(req, res);
}).listen(3000);