diff options
| author | Vladimir Homutov <vl@nginx.com> | 2013-04-03 01:44:36 +0400 |
|---|---|---|
| committer | Aleksei Bavshin <a.bavshin@f5.com> | 2026-03-09 11:08:30 -0600 |
| commit | 104734f21888cfec6994e092073f51a0d4b0fb47 (patch) | |
| tree | 7b63045b3921ee8ae2cacd5e6a79c7be829d507b /auto | |
| parent | dff46cd1ae0095922e7eb9cf5b32ebe1e68a5706 (diff) | |
| download | nginx-104734f21888cfec6994e092073f51a0d4b0fb47.tar.gz nginx-104734f21888cfec6994e092073f51a0d4b0fb47.tar.bz2 | |
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 <ru@nginx.com>
Co-authored-by: Roman Arutyunyan <arut@nginx.com>
Co-authored-by: Maxim Dounin <mdounin@mdounin.ru>
Diffstat (limited to 'auto')
| -rw-r--r-- | auto/modules | 14 | ||||
| -rw-r--r-- | auto/options | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/auto/modules b/auto/modules index c199d89bf..f02691e16 100644 --- a/auto/modules +++ b/auto/modules @@ -950,6 +950,20 @@ if [ $HTTP = YES ]; then . auto/module fi + if [ $HTTP_UPSTREAM_STICKY = YES ]; then + have=NGX_HTTP_UPSTREAM_STICKY . auto/have + have=NGX_HTTP_UPSTREAM_SID . auto/have + + ngx_module_name=ngx_http_upstream_sticky_module + ngx_module_incs= + ngx_module_deps= + ngx_module_srcs=src/http/modules/ngx_http_upstream_sticky_module.c + ngx_module_libs= + ngx_module_link=$HTTP_UPSTREAM_STICKY + + . auto/module + fi + if [ $HTTP_STUB_STATUS = YES ]; then have=NGX_STAT_STUB . auto/have diff --git a/auto/options b/auto/options index 6a6e990a0..271153a76 100644 --- a/auto/options +++ b/auto/options @@ -107,6 +107,7 @@ HTTP_UPSTREAM_LEAST_CONN=YES HTTP_UPSTREAM_RANDOM=YES HTTP_UPSTREAM_KEEPALIVE=YES HTTP_UPSTREAM_ZONE=YES +HTTP_UPSTREAM_STICKY=YES # STUB HTTP_STUB_STATUS=NO @@ -292,6 +293,7 @@ $0: warning: the \"--with-ipv6\" option is deprecated" HTTP_UPSTREAM_RANDOM=NO ;; --without-http_upstream_keepalive_module) HTTP_UPSTREAM_KEEPALIVE=NO ;; --without-http_upstream_zone_module) HTTP_UPSTREAM_ZONE=NO ;; + --without-http_upstream_sticky) HTTP_UPSTREAM_STICKY=NO ;; --with-http_perl_module) HTTP_PERL=YES ;; --with-http_perl_module=dynamic) HTTP_PERL=DYNAMIC ;; @@ -516,6 +518,7 @@ cat << END disable ngx_http_upstream_keepalive_module --without-http_upstream_zone_module disable ngx_http_upstream_zone_module + --without-http_upstream_sticky disable sticky upstream modules --with-http_perl_module enable ngx_http_perl_module --with-http_perl_module=dynamic enable dynamic ngx_http_perl_module |
