Skip to content

Instantly share code, notes, and snippets.

@moeiscool
Created July 23, 2020 04:24
Show Gist options
  • Save moeiscool/3d5681b1a7028346a6d2c22ca46c1eb3 to your computer and use it in GitHub Desktop.
Save moeiscool/3d5681b1a7028346a6d2c22ca46c1eb3 to your computer and use it in GitHub Desktop.
//Testing HTTP Proxy in Node.js
var http = require('http'),
httpProxy = require('http-proxy');
var proxy = httpProxy.createProxyServer({});
var server = http.createServer(function(req, res) {
proxy.web(req, res, { target: 'http://1.1.1.1:80' });
});
var listeningPort = 5050;
var listeningIp = '127.0.0.1';
console.log(`Listening on port ${listeningPort}`)
server.listen(listeningPort,listeningIp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment