Forwarding of external IP when using public urls

Hi,
I try to determine the external IP, if someone is accessing a device using public URL.
However, the IP I receive (using nodejs) is (in my example): 52.4.252.97
Which is an IP address owned by Amazon, and not the external IP of the client accessing the remote device.
Is there a possibility to receive the real external IP of the client?

Thanks

@fritz can you provide the snippet of nodejs code you are using to get the IP address?

@alanb128
Hi,
I’m using
req.clientIp.split(":")[req.clientIp.split(":").length - 1]
in the HTTP Request handler (using express) to obtain the IPv4 address.

Thanks

Hello @fritz did you try to use the PUBLIC IP ADDRESS published on balenaCloud? Having said that, it’s possible that the public ip address is not accessible due modems security reasons.

Hi,
no, as stated, we cannot use the public IP address due to network / modem security.
We need to find out the real client IP when using the public url.
Thanks

Hello, it may not be possible to obtain the client’s IP due to the way the Public URL feature works. I am also experimenting with this as well though, and req.headers['x-forwarded-for'] has gotten me closer. See javascript - How to use "x-forwarded-for" in Node.js (without Express if possible) - Stack Overflow - I will post further progress here.

Hi,
the req.headers['x-forwarded-for'] is empty unfortunately. :frowning:
Any other hints?
Thanks

The accepted answer in the link above worked for me to get the actual client IP on a local network, but no luck so far using the Public URL. I’m still discussing with our back end team to find out definitively if this is possible.

@alanb128 Thanks. Please let me know, if you can get a solution with the back-end team!
Thanks

Hello @fritz unfortunately the current configuration of our Public URL does not pass the client information. We’re looking into options for changing that but I have no ETA at this point. We will keep this thread updated with any new information.