示例#1
0
var server=http.createServer(function(req,res){
    var host=req.headers.host;
    switch(host){
        case "www.jelewine.xyz":
            proxy.web(req,res,{target:"http://localhost:8888"});
            break;
        case "jelewine.xyz":
            proxy.web(req,res,{target:"http://localhost:8888"});
            break;
        default:
            res.writeHead(200,{"Content-Type":"text/plain"});
            res.end("welcome to my server");
    }
})
示例#2
0
文件: app.js 项目: yufanxiaofan/wows
var serverCallback = function (req, res) {
    var proxyIndex = selectServer(req, res);
    console.log("proxyIndex", proxyIndex);
    var proxy = proxies[proxyIndex];
    proxy.web(req, res);

    proxy.on('error', function (err) {
        console.log(err);
        startFailoverTimer(proxyIndex);
    });
};
var server = http.createServer(function(req,res)
{
	server.setMaxListeners(0);
	var proxyIndex = selectServer(req, res);
	var proxy = proxies[proxyIndex];
	//console.log('blancing request to: ',proxy);
	proxy.web(req, res);
	proxy.on('error', function(err) 
	{
		console.log('proxy error',err); 
	});
server.on('error',function(err){
	console.log('server error');
})
});
示例#4
0
http.createServer(function (req, res) {
  var target = options.shift();
  proxy.web(req, res, target);
  options.push(target);
}).listen(4000);