Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
dummy nc web server
{ echo -ne "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/plain\r\n\r\n"; node -v; } | nc.traditional -l -p 8001

tralamazza commented Jul 26, 2011

First run the little nc script (nc.traditional for ubuntu)

Create a simple http proxy:

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

var proxy = new httpProxy.HttpProxy();

proxy.on('proxyError', function(err, req, res) {
  console.log('proxyError: ' + err);

proxy.on('end', function(req, res) {
  console.log('proxy sent a response');

// proxy server
http.createServer(function(req, res) {
  console.log('proxy received a request');
  proxy.proxyRequest(req, res, { host: 'localhost', port: 8001 });

run this node script and execute:

$ curl -v localhost:8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment