How to find out the remote Address in node.js if it is HTTPS request?
It appears something is strange/broken indeed. As of node 0.4.7, it seems http has remoteAddress available on:
- req.connection.remoteAddress
- req.socket.remoteAddress
on https, both of these are undefined, but
- req.connection.socket.remoteAddress
does work. That one isn't available on http though, so you need to check carefully. I cannot imagine this behavior is intentional.
Since googling "express js ip" directly points to here, this is somehow relevant.
Express 3.0.0 alpha now offers a new way of retrieving IP adresses for client requests.
Simply use req.ip
. If you're doing some proxy jiggery-pokery you might be interested in app.set("trust proxy", true);
and req.ips
.
I recommend you to read the whole discussion in the Express Google Group.