直接代码:
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')