http-party / node-http-proxy

A full-featured http proxy for node.js
https://github.com/http-party/node-http-proxy
Other
13.89k stars 1.97k forks source link

Is there an easy way to add SOCKS support? #905

Open zorro765 opened 8 years ago

zorro765 commented 8 years ago

I have the following scenario: The target HTTP server is only reachable via SOCKS. So is there an easy way to hook a SOCKS client in-between node-http-proxy and the target HTTP server?

Kind regards.

jcrugzz commented 8 years ago

@zorro765 this would be accomplished by using an http/https Agent. I haven't tried it but try using node-proxy-agent. I'd love to have a test using this agent to validate.

flyyang commented 6 years ago

@jcrugzz so... how can we solve this in 2018

AlbinoDrought commented 6 years ago

Wanted to do a similar thing here, this is what I ended up doing:

var http = require('http'),
    httpProxy = require('http-proxy'),
    ProxyAgent = require('proxy-agent');

httpProxy.createProxyServer({
  agent: new ProxyAgent('socks5://username:password@some-socks-proxy.com:9050'),
  target:'http://localhost:9000'
}).listen(8000);

You want to use the agent option when configuring this package. You can pass any regular Agent here, a popular one being the listed-above node-proxy-agent.