Changeset 6729:cecf415643d7 in nginx


Ignore:
Timestamp:
10/06/16 20:16:05 (3 years ago)
Author:
Maxim Dounin <mdounin@…>
Branch:
default
Phase:
public
Message:

Realip: fixed duplicate processing on redirects (ticket #1098).

Duplicate processing was possible if the address set by realip was
listed in set_realip_from, and there was an internal redirect so module
context was cleared. This resulted in exactly the same address being set,
so this wasn't a problem before the $realip_remote_addr variable was
introduced, though now results in incorrect $realip_remote_addr being
picked.

Fix is to use ngx_http_realip_get_module_ctx() to look up module context
even if it was cleared. Additionally, the order of checks was switched to
check the configuration first as it looks more effective.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/http/modules/ngx_http_realip_module.c

    r6671 r6729  
    142142    ngx_http_realip_loc_conf_t  *rlcf;
    143143
    144     ctx = ngx_http_get_module_ctx(r, ngx_http_realip_module);
     144    rlcf = ngx_http_get_module_loc_conf(r, ngx_http_realip_module);
     145
     146    if (rlcf->from == NULL) {
     147        return NGX_DECLINED;
     148    }
     149
     150    ctx = ngx_http_realip_get_module_ctx(r);
    145151
    146152    if (ctx) {
    147         return NGX_DECLINED;
    148     }
    149 
    150     rlcf = ngx_http_get_module_loc_conf(r, ngx_http_realip_module);
    151 
    152     if (rlcf->from == NULL) {
    153153        return NGX_DECLINED;
    154154    }
Note: See TracChangeset for help on using the changeset viewer.