Set real ip not working

Francis Daly francis at daoine.org
Wed May 9 20:36:24 UTC 2018


On Wed, May 09, 2018 at 02:19:23PM -0400, snir wrote:

Hi there,

> I want to get the real ip of the client but I'm all ways getting the ip of
> the ngnix server.

What, specifically, do you mean by "getting the ip"?

> I trayed using set_real_ip:

The tcp connection from nginx to upstream will (almost) always come from
an IP address of the nginx machine.

It is possible that nginx can be configured to write a client IP address
into a http header, that the upstream server can then be invited to read.

For that, you will want to make sure to write the client IP address into
a http header (proxy_set_header, perhaps $proxy_add_x_forwarded_for) and
you will want to make sure to configure your upstream server to read it.


For one test request, what is the client IP address that you care
about? Do you see that IP address anywhere in the request from nginx to
upstream? If not, fix that. If so: do you see upstream doing anything
with that part of the request? If not, fix that.

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list