From ba17b9b7656ed26ff5538b32c7621a35c6472742 Mon Sep 17 00:00:00 2001 From: Danila Vershinin Date: Tue, 20 Aug 2019 21:15:40 +0300 Subject: [PATCH 1/4] Update config --- config | 1 + 1 file changed, 1 insertion(+) diff --git a/config b/config index bf9bacc..d058ae6 100644 --- a/config +++ b/config @@ -4,3 +4,4 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_sticky_module.c $ngx_add NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/ngx_http_sticky_misc.h" USE_MD5=YES USE_SHA1=YES +. auto/module From 1daf2fad54a95965ab46425b2024c2efaa12ee09 Mon Sep 17 00:00:00 2001 From: Danila Vershinin Date: Tue, 20 Aug 2019 21:30:44 +0300 Subject: [PATCH 2/4] Update config --- config | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/config b/config index d058ae6..b6bb38d 100644 --- a/config +++ b/config @@ -1,7 +1,16 @@ -ngx_addon_name=ngx_http_sticky_module -HTTP_MODULES="$HTTP_MODULES ngx_http_sticky_module" -NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_sticky_module.c $ngx_addon_dir/ngx_http_sticky_misc.c" NGX_ADDON_DEPS="$NGX_ADDON_DEPS $ngx_addon_dir/ngx_http_sticky_misc.h" USE_MD5=YES USE_SHA1=YES -. auto/module + +ngx_addon_name=ngx_http_sticky_module + +if test -n "$ngx_module_link"; then + ngx_module_type=HTTP + ngx_module_name=ngx_http_sticky_module + ngx_module_srcs="$ngx_addon_dir/ngx_http_sticky_module.c $ngx_addon_dir/ngx_http_sticky_misc.c" + + . auto/module +else + HTTP_MODULES="$HTTP_MODULES ngx_http_sticky_module" + NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_sticky_module.c $ngx_addon_dir/ngx_http_sticky_misc.c" +fi From 1f3d0c2ff7f743546f02134a4e9f7dd85a971af4 Mon Sep 17 00:00:00 2001 From: Danila Vershinin Date: Tue, 20 Aug 2019 21:39:57 +0300 Subject: [PATCH 3/4] Update ngx_http_sticky_module.c --- ngx_http_sticky_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ngx_http_sticky_module.c b/ngx_http_sticky_module.c index 00d2a2e..86d9d11 100644 --- a/ngx_http_sticky_module.c +++ b/ngx_http_sticky_module.c @@ -750,7 +750,7 @@ static char *ngx_conf_set_noargs_slot(ngx_conf_t *cf, ngx_command_t *cmd, void * fp = (ngx_uint_t *) (p + cmd->offset); - if (*fp != NGX_CONF_UNSET) { + if (*fp != NGX_CONF_UNSET_UINT) { return "is duplicate"; } From 275321180e6330d07f5c43751ea8141a52b08e03 Mon Sep 17 00:00:00 2001 From: Danila Vershinin Date: Mon, 27 Jun 2022 21:47:24 +0300 Subject: [PATCH 4/4] >= NGINX 1.23.0 compat --- ngx_http_sticky_module.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ngx_http_sticky_module.c b/ngx_http_sticky_module.c index 86d9d11..15f2eac 100644 --- a/ngx_http_sticky_module.c +++ b/ngx_http_sticky_module.c @@ -215,7 +215,11 @@ static ngx_int_t ngx_http_init_sticky_peer(ngx_http_request_t *r, ngx_http_upstr iphp->request = r; /* check weather a cookie is present or not and save it */ +#if defined(nginx_version) && nginx_version >= 1023000 + 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); @@ -351,8 +355,8 @@ static ngx_int_t ngx_http_get_sticky_peer(ngx_peer_connection_t *pc, void *data) iphp->rrp.current = peer; #else iphp->rrp.current = iphp->selected_peer; -#endif - +#endif + pc->cached = 0; pc->connection = NULL; pc->sockaddr = peer->sockaddr; @@ -679,7 +683,7 @@ static char *ngx_http_sticky_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) upstream_conf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module); - /* + /* * ensure another upstream module has not been already loaded * peer.init_upstream is set to null and the upstream module use RR if not set * But this check only works when the other module is declared before sticky