一般默认都是已经配置好的
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
如果是 Caddy 配置就更简单了
proxy / 127.0.0.1:3000 {
transparent
}
请参考如下示例
let ip = req.get('X-Real-IP') || req.get('X-Forwarded-For') || req.ip;
console.log(ip);
© 2020 飞鱼的博客