Fast, lightweight and transparent http(s) proxy that supports dynamic hostnames.
npm install host-proxyvar createProxy = require('host-proxy');
// Start a proxy server.
createProxy(function (hostname, secure) {
// Respond with an address to proxy to.
// Result is passed to net.createConnection.
return ({
"test.com": "http://localhost:3002",
"secure.test.com": "https://localhost:3003",
"search.test.com": "http://google.ca",
"api.test.com": { port: 12345, family: 'IPv4', address: "127.0.0.1" }
})[hostname];
}).listen(80);- test.com -> http://localhost:3002
- secure.test.com -> https://localhost:3003
- search.test.com -> http://google.ca
- api.test.com -> http://localhost:12345
- Use npm to run tests.
Please feel free to create a PR!