nodejs简易代理服务器

直接代码:

var http = require('http')
var proxy = http.createServer(function (request, response) {
  var options = {
    host: 'www.cnblogs.com', // 这里是代理服务器       
    port: 80, // 这里是代理服务器端口
    path: request.url,
    method: request.method
  }
  var req = http.request(options, function (res) {
    res.pipe(response);
  }).end();

}).listen(3000, 'localhost')

  

posted @ 2017-04-27 12:47  程序员小波与Bug  阅读(348)  评论(0编辑  收藏  举报