# HG changeset patch # User Ruslan Ermilov # Date 1382527178 -14400 # Node ID 3056640d5022c54fa1b27f90b163a8a1c3831c1e # Parent 36cf06691ff127d3a4902fed1149d9865f772b13 Upstream: documented new "sticky" features. diff -r 36cf06691ff1 -r 3056640d5022 xml/en/docs/http/ngx_http_upstream_module.xml --- a/xml/en/docs/http/ngx_http_upstream_module.xml Wed Dec 11 09:17:55 2013 +0400 +++ b/xml/en/docs/http/ngx_http_upstream_module.xml Wed Oct 23 15:19:38 2013 +0400 @@ -10,7 +10,7 @@ + rev="12">
@@ -203,6 +203,14 @@ the directive. +route=string + +sets the server route name. + +This functionality is available as part of our only. + + + @@ -693,24 +701,32 @@ - -name + +cookie name [expires=time] -[domain=host] +[domain=domain] [path=path] +route variable ... upstream +1.5.7 Enables session affinity, which causes requests from the same client to be passed to the same server in a group of servers. -Example: +Two methods are available, +cookie and route. + + + +When the cookie method is used, information about the +designated server is passed in an HTTP cookie: upstream backend { server backend1.example.com; server backend2.example.com; - sticky_cookie_insert srv_id expires=1h domain=example.com path=/; + sticky cookie srv_id expires=1h domain=.example.com path=/; } @@ -719,20 +735,19 @@ A request that comes from a client not yet bound to a particular server is passed to the server selected by the configured balancing method. Further requests from the same client are passed to the same server. -If a request cannot be processed by the bound server, the new server -is selected as if the client was not yet bound. +If the designated server cannot process a request, the new server is +selected as if the client has not been bound yet. -Information about the bound server is kept in an HTTP cookie. -The first parameter sets the name of the cookie to be inserted or inspected. +The first parameter sets the name of the cookie to be set or inspected. Additional parameters may be as follows: expires Sets the time for which a browser should keep the cookie. -The parameter max will cause the cookie to expire on +The special value max will cause the cookie to expire on “31 Dec 2037 23:55:55 GMT”. This is the maximum time understood by old browsers. If the parameter is not specified, it will cause the cookie to expire at @@ -754,6 +769,48 @@ +When the route method is used, proxied server assigns +client a route on receipt of the first request. +All subsequent requests from this client will carry routing information +in a cookie or URI. +This information is compared with the “route” parameter +of the directive to identify the server to which the +request should be proxied. +If the designated server cannot process a request, the new server is +selected by the configured balancing method as if there is no routing +information in the request. + + + +The parameters of the route method specify variables that +may contain routing information. +The first non-empty variable is used to find the matching server. + + + +Example: + +map $cookie_jsessionid $route_cookie { + ~.+\.(?P<route>\w+)$ $route; +} + +map $request_uri $route_uri { + ~jsessionid=.+\.(?P<route>\w+)$ $route; +} + +upstream backend { + server backend1.example.com route=a; + server backend2.example.com route=b; + + sticky route $route_cookie $route_uri; +} + +Here, the route is taken from the “JSESSIONID” cookie +if present in a request. +Otherwise, the route from the URI is used. + + + This directive is available as part of our only. @@ -762,6 +819,29 @@ + +name +[expires=time] +[domain=domain] +[path=path] + +upstream + + +This directive is obsolete since version 1.5.7. +An equivalent + directive with a new syntax should be used instead: + +sticky cookie name +[expires=time] +[domain=domain] +[path=path]; + + + + + + @@ -893,6 +973,13 @@ of the directive. + +route=string + +Same as the “route” parameter +of the directive. + + The first three parameters select a target the command applies to.