nginx/auto
Vladimir Homutov 104734f218 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>
2026-03-09 11:08:30 -06:00
..
cc Configure: ensure we get the "built by ..." line in nginx -V. 2025-11-04 16:11:53 +00:00
lib Configure: MSVC compatibility with PCRE2 10.47. 2025-11-06 15:34:58 +04:00
os Core: added support for TCP keepalive parameters on macOS. 2025-05-27 01:59:02 +04:00
types Configure: stop polluting NGX_ namespace. 2016-06-27 15:00:06 -07:00
configure Win32: i386 now assumed when crossbuilding (ticket #2416). 2023-02-23 18:15:59 +03:00
define Copyright updated. 2012-01-18 15:07:43 +00:00
endianness Configure: fix build with -Werror=old-style-definition. 2016-06-27 15:00:05 -07:00
feature Configure: fix build with -Werror=old-style-definition. 2016-06-27 15:00:05 -07:00
have Copyright updated. 2012-01-18 15:07:43 +00:00
have_headers Copyright updated. 2012-01-18 15:07:43 +00:00
headers Copyright updated. 2012-01-18 15:07:43 +00:00
include Configure: stop polluting NGX_ namespace. 2016-06-27 15:00:06 -07:00
init Configure: marked top-level make targets as phony. 2021-02-20 12:44:26 +03:00
install Configure: fixed "make install" when cross-compiling to Windows. 2024-02-26 20:00:46 +00:00
make Configure: ordered directories. 2021-09-21 14:46:25 +03:00
module Configure: shared sources for addon modules. 2020-11-10 17:13:20 +03:00
modules Upstream: added sticky sessions support for upstreams. 2026-03-09 11:08:30 -06:00
nohave Copyright updated. 2012-01-18 15:07:43 +00:00
options Upstream: added sticky sessions support for upstreams. 2026-03-09 11:08:30 -06:00
sources Core: the ngx_event_udp.h header file. 2022-01-25 15:41:48 +03:00
stubs Copyright updated. 2012-01-18 15:07:43 +00:00
summary PCRE2 library support. 2021-12-25 01:07:15 +03:00
threads Configure: fixed static compilation with OpenSSL 1.1.1. 2018-03-22 15:55:57 +03:00
unix Configure: set NGX_KQUEUE_UDATA_T at compile time. 2025-07-11 16:25:51 +04:00