13 #define NGX_HTTP_REALIP_XREALIP 0
14 #define NGX_HTTP_REALIP_XFWD 1
15 #define NGX_HTTP_REALIP_HEADER 2
38 static void ngx_http_realip_cleanup(
void *data);
42 static void *ngx_http_realip_create_loc_conf(
ngx_conf_t *cf);
43 static char *ngx_http_realip_merge_loc_conf(
ngx_conf_t *cf,
44 void *parent,
void *child);
86 ngx_http_realip_create_loc_conf,
87 ngx_http_realip_merge_loc_conf
93 &ngx_http_realip_module_ctx,
94 ngx_http_realip_commands,
130 if (rlcf->
from == NULL) {
134 switch (rlcf->
type) {
151 if (xfwd->
elts == NULL) {
170 if (i >= part->
nelts) {
171 if (part->
next == NULL) {
180 if (hash == header[i].hash
181 && len == header[i].key.len
182 &&
ngx_strncmp(p, header[i].lowcase_key, len) == 0)
206 return ngx_http_realip_set_addr(r, &addr);
245 cln->
handler = ngx_http_realip_cleanup;
262 ngx_http_realip_cleanup(
void *data)
287 if (rlcf->
from == NULL) {
290 if (rlcf->
from == NULL) {
300 #if (NGX_HAVE_UNIX_DOMAIN)
302 if (
ngx_strcmp(value[1].data,
"unix:") == 0) {
319 "low address bits of %V are meaningless", &value[1]);
335 if (
ngx_strcmp(value[1].data,
"X-Real-IP") == 0) {
340 if (
ngx_strcmp(value[1].data,
"X-Forwarded-For") == 0) {
354 ngx_http_realip_create_loc_conf(
ngx_conf_t *cf)
379 ngx_http_realip_merge_loc_conf(
ngx_conf_t *cf,
void *parent,
void *child)
384 if (conf->
from == NULL) {
413 *h = ngx_http_realip_handler;
420 *h = ngx_http_realip_handler;