Welcome! Log In Create A New Profile

Advanced

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

Maxim Dounin
October 06, 2016 04:18PM
details: http://hg.nginx.org/nginx/rev/cecf415643d7
branches:
changeset: 6729:cecf415643d7
user: Maxim Dounin <mdounin@mdounin.ru>
date: Thu Oct 06 23:16:05 2016 +0300
description:
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.

diffstat:

src/http/modules/ngx_http_realip_module.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diffs (23 lines):

diff --git a/src/http/modules/ngx_http_realip_module.c b/src/http/modules/ngx_http_realip_module.c
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -141,15 +141,15 @@ ngx_http_realip_handler(ngx_http_request
ngx_http_realip_ctx_t *ctx;
ngx_http_realip_loc_conf_t *rlcf;

- ctx = ngx_http_get_module_ctx(r, ngx_http_realip_module);
+ rlcf = ngx_http_get_module_loc_conf(r, ngx_http_realip_module);

- if (ctx) {
+ if (rlcf->from == NULL) {
return NGX_DECLINED;
}

- rlcf = ngx_http_get_module_loc_conf(r, ngx_http_realip_module);
+ ctx = ngx_http_realip_get_module_ctx(r);

- if (rlcf->from == NULL) {
+ if (ctx) {
return NGX_DECLINED;
}


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

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

Maxim Dounin 345 October 06, 2016 04:18PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 192
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready