From d99ae8efe74459c09480d61a3632c0619823bf5e Mon Sep 17 00:00:00 2001 From: xuge <1827761427@qq.com> Date: Wed, 13 Sep 2023 10:31:49 +0800 Subject: [PATCH 1/2] Fix for nginx >= 1.23.0 API change --- ngx_http_sticky_module.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ngx_http_sticky_module.c b/ngx_http_sticky_module.c index 3b94741..65d62df 100644 --- a/ngx_http_sticky_module.c +++ b/ngx_http_sticky_module.c @@ -240,7 +240,13 @@ static ngx_int_t ngx_http_init_sticky_peer(ngx_http_request_t *r, ngx_http_upstr ngx_http_set_ctx(r, iphp, ngx_http_sticky_module); /* check weather a cookie is present or not and save it */ + +#if defined(nginx_version) && nginx_version >= 1023000 + /* nginx-1.23.0+ compatibility */ + if (ngx_http_parse_multi_header_lines(r, r->headers_in.cookie, &iphp->sticky_conf->cookie_name, &route) != NULL) { +#else if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &iphp->sticky_conf->cookie_name, &route) != NGX_DECLINED) { +#endif /* a route cookie has been found. Let's give it a try */ ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "[sticky/init_sticky_peer] got cookie route=%V, let's try to find a matching peer", &route); @@ -472,7 +478,12 @@ static ngx_int_t ngx_http_sticky_header_filter(ngx_http_request_t *r) } if (ctx->sticky_conf->transfer_cookie) { + #if defined(nginx_version) && nginx_version >= 1023000 + /* nginx-1.23.0+ compatibility */ + if (ngx_http_parse_set_cookie_lines(r, r->upstream->headers_in.set_cookie, &ctx->sticky_conf->cookie_name, &transfer_cookie) == NULL) + #else if (ngx_http_parse_set_cookie_lines(&r->upstream->headers_in.cookies, &ctx->sticky_conf->cookie_name, &transfer_cookie) == NGX_DECLINED) + #endif { ngx_str_null(&transfer_cookie); } From 125de08203ac1fec8b70807b5353c5477bce0f0e Mon Sep 17 00:00:00 2001 From: xuge <1827761427@qq.com> Date: Wed, 13 Sep 2023 11:07:29 +0800 Subject: [PATCH 2/2] Fix macro redefined --- ngx_http_sticky_misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ngx_http_sticky_misc.c b/ngx_http_sticky_misc.c index d1ee110..3981bed 100644 --- a/ngx_http_sticky_misc.c +++ b/ngx_http_sticky_misc.c @@ -17,11 +17,11 @@ #endif /* - fix for 1.11.2 removes include in ngx_md5.h */ +#ifndef MD5_CBLOCK #define MD5_CBLOCK 64 #define MD5_LBLOCK (MD5_CBLOCK/4) #define MD5_DIGEST_LENGTH 16 -#define SHA_CBLOCK 64 -#define SHA_DIGEST_LENGTH 20 +#endif #ifndef SHA_DIGEST_LENGTH #define SHA_CBLOCK 64