Open rohitkhatri opened 6 years ago
I have the same issue here. I read that the only way to fix this is by using a cookie instead of the remoteAddress.
same issue,I have no idea how to solve this problem..
I think we can forward the client ip address from nginx reverse proxy settings
You may want to use the following to get the real IP of the client
const ip = req.headers["x-forwarded-for"] || req.connection.remoteAddress;
as the proxy (HAProxy in my case) sends the IP of the client on the header as "x-forwarded-for"
You may want to use the following to get the real IP of the client
const ip = req.headers["x-forwarded-for"] || req.connection.remoteAddress;
as the proxy (HAProxy in my case) sends the IP of the client on the header as "x-forwarded-for"
Where can we access the request object?
The
connection.remoteAddress
is always127.0.0.1
when usingnginx
reverse proxy.