diff --git a/ngx_http_sticky_module.c b/ngx_http_sticky_module.c index 3b94741..d50e9c2 100644 --- a/ngx_http_sticky_module.c +++ b/ngx_http_sticky_module.c @@ -240,7 +240,11 @@ 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 + 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); @@ -390,8 +394,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; @@ -830,7 +834,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