node.js app proxy

علی ذوالفقار
1400/05/19 10:33:02 (648)
// Create the proxy
var proxy = require('redbird')({
    port: 80 , 
    xfwd : true ,  // pass client ip address (retrivable via request-ip module)
    cluster : 4 ,  // cluster proxy on 4 cpu core 
})
// register apps in proxy 
proxy.register("stinq.ipo.org", "http://127.0.0.1:81");
proxy.register("investors.ipo.org", "http://127.0.0.1:82");
test :
const requestIp = require('request-ip');
var port = 81;
console.log('start port on port ', port);
var http = require('http').createServer((req, res,netx) => {
    const clientIp = requestIp.getClientIp(req); 
    console.log('request from : ' , clientIp);
    res.write('Hello World! on port ', port);
    res.end();
}).listen(port);
Back