http req 개체에서 클라이언트 IP 주소를 얻으려면 어떻게해야합니까?node.js http 요청 개체에서 클라이언트 IP를 가져옵니다.
IE는 :
var util = require('util'),
colors = require('colors'),
http = require('http'),
httpProxy = require('../../lib/node-http-proxy');
//
// Http Server with proxyRequest Handler and Latency
//
var proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) {
// GET IP address here
// var ip = ??
var buffer = httpProxy.buffer(req);
setTimeout(function() {
proxy.proxyRequest(req, res, {
port: 9000,
host: 'localhost',
buffer: buffer
});
}, 200);
}).listen(8004);
프록시 서버의 기본 표준은'X-Forwarded-For'입니다. 대부분의 캐싱 프록시는 기본적으로 지원되며 nginx에서 다음과 같이 설정할 수 있습니다 :'proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;' –