Where does $remote_addr come from?

Francis Daly francis at daoine.org
Fri Feb 3 08:35:03 UTC 2017


On Thu, Feb 02, 2017 at 05:02:43PM -0500, Paul Nickerson wrote:

Hi there,

> Currently, my best guess is that it's the source address
> field in the incoming TCP/IP packet's IPv4 internet header. Is this
> correct? Or, does it come from somewhere else?

grep -lr remote_addr .

in the source tree shows a handful of files where it is used, "grep -r"
shows only one or two where it is probably set.

For http, it is set in ./src/http/ngx_http_variables.c

Roughly, it is the IP address of the incoming connection, unless the
realip module has replaced it with something else.

Exactly, it is what the source code says:

    v->data = r->connection->addr_text.data;

and then you can track where that addr_text.data value is set.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list