Skip to content

Instantly share code, notes, and snippets.

@getnamo
Last active March 29, 2019 18:45
Show Gist options
  • Save getnamo/b57c37a8929c75d127f1c8827670937d to your computer and use it in GitHub Desktop.
Save getnamo/b57c37a8929c75d127f1c8827670937d to your computer and use it in GitHub Desktop.
simple node.js proxy. Allowing to tear down and bring up as needed. Usage: node proxy.js <from port> <to port>. Forever recommended.
let from = 80;
let to = 8080;
const httpProxy = require('http-proxy');
if(process.argv.length != 4){
console.log('Did not supply from/to params, remapping ' + from + ' to ' + to);
}
else{
from = Number(process.argv[2]);
to = Number(process.argv[3]);
}
const proxy = httpProxy.createProxyServer({target:'http://localhost:'+to}).listen(from);
console.log('Proxy running from ' + from + ' to ' + to);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment