在 nginx.conf 中配置:
proxy_set_header X-Real-IP $remote_addr;
在 node.js 中获取 ip:
const ip = req.headers['x-real-ip'] || req.connection.remoteAddress;
在 nginx.conf 中配置:
proxy_set_header X-Real-IP $remote_addr;
在 node.js 中获取 ip:
const ip = req.headers['x-real-ip'] || req.connection.remoteAddress;