분류 Nodejs

http-proxy - HTTP 프록시.

컨텐츠 정보

  • 조회 304 (작성일 )

본문

https://github.com/nodejitsu/node-http-proxy


68747470733a2f2f7261772e6769746875622e636f6d2f6e6f64656a697473752f6e6f64652d687474702d70726f78792f6d61737465722f646f632f6c6f676f2e706e67 


var http = require('http'),
    httpProxy = require('http-proxy');
//
// Create your proxy server and set the target in the options.
//
httpProxy.createProxyServer({target:'http://localhost:9000'}).listen(8000); // See (†)

//
// Create your target server
//
http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
}).listen(9000);