How do I see the real IP address of a connection through a NodeBalancer?

When using a NodeBalancer what's the best way to track where the connections actually come from? Is it possible to get the real IP address information once the connection reaches one of the Linodes behind the NodeBalancer?

2 Replies

Linode Staff

When using a NodeBalancer in HTTP or HTTPS mode the Apache X-Forwarded-For header is added in for each connection with the original IP address for the connection. In TCP mode the packets aren't altered in any way, so there's no additional information added.

You can use the X-Forwarded-For header in a number of different ways. With Apache you could either use mod_rpaf or mod_remoteip to make sure the info provided by X-Forwarded-For is treated as the real IP address of the connection. With mod_remoteip installed for example, you can include the following directive in your site's configuration:

RemoteIPHeader X-Forwarded-For

For Nginx you can use ngx_http_realip_module and include these two lines in your Nginx configuration:

real_ip_header X-Forwarded-For;
set_real_ip_from 192.168.255.0/24;

The private IP address range mentioned there is the address range that we use for communications between a NodeBalancer and a Linode.

Hi,

Sorry to jump in here, I was just wondering if I could clarify the following statement?

… In TCP mode the packets aren't altered in any way, so there's no additional information added.

Do you mean the original packet from the client's browser, or the packet originating from the NodeBalancer?

I.e. will a service running via TCP see the client's original IP, or the NodeBalancer's?

Also, you said that you use the range 192.168.255.0/24 for communication to backend Linodes. Doesn't this mean you're limited to 255 NodeBalancers per data-centre?

Reply

Please enter an answer
Tips:

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] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct