Running a forward proxy server in nodejitsu using node js

2.4k views Asked by At

I am new to proxy server. What I want to do is: I want to write some node.js code, and then upload to my nodejitsu account to run as a proxy server. Then I would like to use my nodejitsu proxy server on my computer, by configuring the http proxy as "abc.jit.su" (my jitsu URL), and the port as "80" in Chrome, Firefox or IE. That's to say, I want my nodejitsu proxy server to have the same function as the proxies listed here: http://www.freeproxylists.net/. Any ideas?

1

There are 1 answers

0
Andrew On

You can write a simple proxy using the request module, like this:

var http = require('http'),
    request = require('request');

// For nodejitsu, this will be port 80 externally
var port = process.env.PORT || 8000;

http.createServer(function(req,res) {
  req.pipe(request(req.url)).pipe(res)
}).listen(port);

However, this will only work with http, not https.

Nodejitsu also produces a proxy module, you may get some ideas on what to do next by looking at that.