RejectedSoftware Forums

Sign up

How do I get remote_addr?

Hi,

I want to save IP address for login members. How do I get IP address?

Re: How do I get remote_addr?

On Thu, 27 Oct 2016 11:11:47 GMT, can wrote:

Hi,

I want to save IP address for login members. How do I get IP address?

You can get the raw address using HTTPServerRequest.clientAddress and .toAddressString() will convert that to an IP address string.

Re: How do I get remote_addr?

On Thu, 27 Oct 2016 18:11:55 GMT, Sönke Ludwig wrote:

On Thu, 27 Oct 2016 11:11:47 GMT, can wrote:

Hi,

I want to save IP address for login members. How do I get IP address?

You can get the raw address using HTTPServerRequest.clientAddress and .toAddressString() will convert that to an IP address string.

OK. but this code always get 127.0.0.1 IP address. My project is behind nginx server and I want get client IP e.g. 187.95.121.48?

Re: How do I get remote_addr?

Am 29.10.2016 um 11:04 schrieb can:

On Thu, 27 Oct 2016 18:11:55 GMT, Sönke Ludwig wrote:

On Thu, 27 Oct 2016 11:11:47 GMT, can wrote:

Hi,

I want to save IP address for login members. How do I get IP address?

You can get the raw address using HTTPServerRequest.clientAddress and .toAddressString() will convert that to an IP address string.

OK. but this code always get 127.0.0.1 IP address. My project is behind nginx server and I want get client IP e.g. 187.95.121.48?

Ah okay, in that case you'd have to configure Nginx to forward the
client's IP as an HTTP header:

 proxy_set_header X-Real-IP $remote_addr;

Then the IP would be accessible as req.headers["X-Real-IP"].