Reading from variable in config file


#1

Hi all,
I need to read client’s IP to store it in module context:

{ ngx_string(“real_ip”),
NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_my_loc_conf_t, realIp),
NULL },

and in config file:
real_ip $proxy_add_x_forwarded_for;

but then it stores not value, but value’s name
($proxy_add_x_forwarded_for). This line is put in the same location
where

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

is, which works fine, so client’s ip must be there :slight_smile:

Or there is mayby another way to get $proxy_add_x_forwarded_for from
inside of my module?

thanks in advance,
mobczynski


#2

IP is stored in r->connection->addr_text as shown in method that sets
variable x-forwarded-for