comparison src/http/modules/ngx_http_realip_module.c @ 6729:cecf415643d7

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 06 Oct 2016 23:16:05 +0300
parents 6b1b8c4b7a95
children df1a62c83b1b
comparison
equal deleted inserted replaced
6728:8f75d9883730 6729:cecf415643d7
139 ngx_table_elt_t *header; 139 ngx_table_elt_t *header;
140 ngx_connection_t *c; 140 ngx_connection_t *c;
141 ngx_http_realip_ctx_t *ctx; 141 ngx_http_realip_ctx_t *ctx;
142 ngx_http_realip_loc_conf_t *rlcf; 142 ngx_http_realip_loc_conf_t *rlcf;
143 143
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);
145 151
146 if (ctx) { 152 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) {
153 return NGX_DECLINED; 153 return NGX_DECLINED;
154 } 154 }
155 155
156 switch (rlcf->type) { 156 switch (rlcf->type) {
157 157