Getting the real client ip on NodeJs behind a NodeBalancer

Hi all!

I have a Kubernetes cluster and my Linodes are running NodeJs. On my Linode I need to get the IP of the client that requested the application. These x-forwarded-for, x-real-ip, remote-address headers do not work, I even tried with upper and lower case. They always return the IP of the NodeBalancer.

These tutorials are what I found about this topic, but nothing works with NodeJs.

Would be great if someone already faced this challenge and could provide a proper solution. Thanks in advance :)

1 Reply

According to the Kubernetes Documentation you should be able to preserve the client's IP by setting the load balancer service's externalTrafficPolicy to local. This should allow you to view the IP address of the client connecting to your node.js application.
This answer from this question on Stack Exchange has a bit more information related to the issue.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct