I host an node.js server with express.js in a docker container. The address of my container is 172.17.0.62 And I use nginx to redirect the traffic to 172.17.0.62
I can access the my server. But when I use
console.log(req.ip + ' ' + req.protocol + ' ' + req.originalUrl);
to log the traffic. req.ip is always 172.17.42.1. I want to get the ip of viewer of my webpage
I use this in my nginx configuration
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
and
cat /proc/sys/net/ipv4/ip_forward # output 1