var http=require("http"); var url=require("url"); var server=http.createServer(function(req,res){ var url_parts=url.parse(req.url); console.log(url_parts); var opts={ host:"210.14.152.181", port:8188, path:url_parts.pathname, headers:req.headers }; var creq=http.get(opts, function (cres) { res.writeHead(cres.statusCode,cres.headers); cres.pipe(res); }); req.pipe(creq); }); server.listen(1337,"127.0.0.1", function () { console.log("开始监听"+server.address().port+"......"); });