标签:
var proxy = require(‘http-proxy‘).createProxyServer({}); proxy.on(function(err, req, res) { res.writeHead(500, { ‘Content-Type‘: ‘text/plain‘ }); }); var server = require(‘http‘).createServer(function(req, res) { var host = req.headers.host; switch (host) { case ‘demo.maomao.gift‘: proxy.web(req, res, { target: ‘http://localhost:3000‘ }); break; case ‘famanoder.com‘: proxy.web(req, res, { target: ‘http://localhost:4030‘ }); break; default: res.writeHead(200, { ‘Content-Type‘: ‘text/plain‘ }); res.end(‘Welcome to my server!‘); } }); console.log("listening on port 80") server.listen(80);
标签:
原文地址:http://www.cnblogs.com/delicious28/p/5619941.html