From 104734f21888cfec6994e092073f51a0d4b0fb47 Mon Sep 17 00:00:00 2001 From: Vladimir Homutov Date: Wed, 3 Apr 2013 01:44:36 +0400 Subject: Upstream: added sticky sessions support for upstreams. Sticky sessions allow to route the same client to the same upstream server. - upstream structures are extended to keep session-related information - existing balancing modules are updated to provide an id of the selected server (SID) in pc->sid, and to select the server, given it's SID. - other balancing modules are allowed to set the pc->hint value to choose the desired peer. The sticky module will not change the hint if it's already set. - the feature is enabled by default and can be disabled with the "--without-http_upstream_sticky" switch of the configure script. The following configuration can be used to enable sticky sessions for supported balancing modules: upstream u1 { server 127.0.0.1:8080; server 127.0.0.1:8081; sticky cookie server_id expires=1h domain=.example.com path=/; } Co-authored-by: Ruslan Ermilov Co-authored-by: Roman Arutyunyan Co-authored-by: Maxim Dounin --- src/event/ngx_event_connect.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/event') diff --git a/src/event/ngx_event_connect.h b/src/event/ngx_event_connect.h index d3b23782e..e428e7376 100644 --- a/src/event/ngx_event_connect.h +++ b/src/event/ngx_event_connect.h @@ -60,6 +60,11 @@ struct ngx_peer_connection_s { ngx_log_t *log; +#if (NGX_HTTP_UPSTREAM_SID || NGX_COMPAT) + ngx_str_t *hint; + ngx_str_t *sid; +#endif + unsigned cached:1; unsigned transparent:1; unsigned so_keepalive:1; @@ -68,7 +73,7 @@ struct ngx_peer_connection_s { /* ngx_connection_log_error_e */ unsigned log_error:2; - NGX_COMPAT_BEGIN(2) + NGX_COMPAT_BEGIN(1) NGX_COMPAT_END }; -- cgit