Last active
March 29, 2019 18:45
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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