public
Created

dummy nc web server

  • Download Gist
gistfile1.sh
Shell
1
{ 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

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 });
}).listen(8000);

run this node script and execute:

$ curl -v localhost:8000

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.