Skip to content

Instantly share code, notes, and snippets.

@DanNi0130
Created August 3, 2018 00:19
Show Gist options
  • Save DanNi0130/2d7fa16fdabef4c600e69c315d8140e9 to your computer and use it in GitHub Desktop.
Save DanNi0130/2d7fa16fdabef4c600e69c315d8140e9 to your computer and use it in GitHub Desktop.
const proxies = {
'useragent1': 'http://proxyusername1:proxypassword1@proxyhost1:proxyport1',
'useragent2': 'http://proxyusername2:proxypassword2@proxyhost2:proxyport2',
'useragent3': 'http://proxyusername3:proxypassword3@proxyhost3:proxyport3',
};
const server = new ProxyChain.Server({
port: 8000,
prepareRequestFunction: ({request}) => {
const userAgent = request.headers['user-agent'];
const proxy = proxies[userAgent];
return {
upstreamProxyUrl: proxy,
};
});
});
server.listen(() => console.log('proxy server started'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment