Get the IP Addres from a user


#1

Enonic version: 6.15.5
OS: Win10

Hello there,

It is possible with GeoIP Lib get the IP address of a Client? Or is needed to get the IP Address with another tool and then use it to obtain geo info from this lib, considering this case do you know a way to obtain the ip address of a user?

In another thread I foud that in the client request is a node called “remoteAddress” but it seems to be the IP address of the server (in my case localhost. “remoteAddress”: “127.0.0.1”) not my public IP

Im look forward to your thoughts regarding this.

Thank you in advance.


#2

GeoIP lib doesn’t return an IP address, it resolves geolocation based on provided IP address. So yes, you will have to fetch the IP address with another tool first. There are lots of public APIs that let you do that, for example https://www.ipify.org/


#3

I think Alan may have misunderstood you?
If you place GeoIP lib in an XP app, you may use it to resolve the geoLocation of the client.

NB! For this to work, you need to get the actual client IP in the request, as this is not always available. For instance if XP is behind a proxy or similar.


#4

There are some moral issues using/getting client ip.
I would avoid this if at all possible and warn the user if your using the data.
And if your are saving the IP address you have to warn the user and ask for concent by GDPR law (If the user falls under the EU laws). Read up on GDPR rules and how to follow them.