comparison xml/en/docs/http/ngx_http_upstream_module.xml @ 1001:35ae9ded0465

Updated the "sticky" directive description. The "sticky_cookie_insert" directive is deprecated. The "sticky cookie" provides the same functionality.
author Vladimir Homutov <vl@nginx.com>
date Thu, 03 Oct 2013 17:02:58 +0400
parents a060ab6fb4be
children 271e735e4576
comparison
equal deleted inserted replaced
1000:88c30759f2ff 1001:35ae9ded0465
8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> 8 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
9 9
10 <module name="Module ngx_http_upstream_module" 10 <module name="Module ngx_http_upstream_module"
11 link="/en/docs/http/ngx_http_upstream_module.html" 11 link="/en/docs/http/ngx_http_upstream_module.html"
12 lang="en" 12 lang="en"
13 rev="11"> 13 rev="12">
14 14
15 <section id="summary"> 15 <section id="summary">
16 16
17 <para> 17 <para>
18 The <literal>ngx_http_upstream_module</literal> module 18 The <literal>ngx_http_upstream_module</literal> module
700 700
701 </directive> 701 </directive>
702 702
703 703
704 <directive name="sticky"> 704 <directive name="sticky">
705 <syntax><literal>cookie</literal> <value>name</value>
706 [<literal>expires=</literal><value>time</value>]
707 [<literal>domain=</literal><value>domain</value>]
708 [<literal>path=</literal><value>path</value>]</syntax>
705 <syntax><literal>route</literal> <value>variable</value> ...</syntax> 709 <syntax><literal>route</literal> <value>variable</value> ...</syntax>
706 <default/> 710 <default/>
707 <context>upstream</context> 711 <context>upstream</context>
708 712 <appeared-in>1.5.7</appeared-in>
709 <para>
710 Enables session affinity, which causes requests that contain route to the
711 server to be passed to this server in a group of servers.
712 Example:
713 <example>
714 map $cookie_JSESSIONID $route_cookie {
715 ~.+\.(?P&lt;route>\w+)$ $route;
716 }
717
718 map $request_uri $route_uri {
719 ~jsessionid=.+\.(?P&lt;route>\w+)$ $route;
720 }
721
722 upstream backend {
723 server backend1.example.com route=a;
724 server backend2.example.com route=b;
725
726 sticky route $route_cookie $route_uri;
727 }
728 </example>
729 Here, the “<literal>JSESSIONID</literal>” cookie is inspected for a server
730 route first, and if not found, the route from the URI is used.
731 </para>
732
733 <para>
734 A request that does not contain a server route is passed to the server
735 selected by the configured balancing method.
736 If a request cannot be processed by the designated server, the new server
737 is selected as if the client has not been bound yet.
738 </para>
739
740 <para>
741 The directive specifies variables that are examined for the route.
742 This route is compared with routes specified in the <link id="server"/>
743 directives.
744 The first non-empty variable is used for server search.
745 </para>
746
747 <para>
748 <note>
749 This directive is available as part of our <commercial_version/> only.
750 </note>
751 </para>
752
753 </directive>
754
755
756 <directive name="sticky_cookie_insert">
757 <syntax><value>name</value>
758 [<literal>expires=</literal><value>time</value>]
759 [<literal>domain=</literal><value>host</value>]
760 [<literal>path=</literal><value>path</value>]</syntax>
761 <default/>
762 <context>upstream</context>
763 713
764 <para> 714 <para>
765 Enables session affinity, which causes requests from the same client to be 715 Enables session affinity, which causes requests from the same client to be
766 passed to the same server in a group of servers. 716 passed to the same server in a group of servers.
767 Example: 717 Two methods are available,
718 <literal>cookie</literal> and <literal>route</literal>.
719 </para>
720
721 <para>
722 When the <literal>cookie</literal> method is used, information about the
723 designated server is passed in an HTTP cookie:
768 <example> 724 <example>
769 upstream backend { 725 upstream backend {
770 server backend1.example.com; 726 server backend1.example.com;
771 server backend2.example.com; 727 server backend2.example.com;
772 728
773 sticky_cookie_insert srv_id expires=1h domain=example.com path=/; 729 sticky cookie srv_id expires=1h domain=.example.com path=/;
774 } 730 }
775 </example> 731 </example>
776 </para> 732 </para>
777 733
778 <para> 734 <para>
779 A request that comes from a client not yet bound to a particular server 735 A request that comes from a client not yet bound to a particular server
780 is passed to the server selected by the configured balancing method. 736 is passed to the server selected by the configured balancing method.
781 Further requests from the same client are passed to the same server. 737 Further requests from the same client are passed to the same server.
782 If a request cannot be processed by the designated server, the new server 738 If the designated server cannot process a request, the new server is
783 is selected as if the client has not been bound yet. 739 selected as if the client has not been bound yet.
784 </para> 740 </para>
785 741
786 <para> 742 <para>
787 Information about the bound server is kept in an HTTP cookie. 743 The first parameter sets the name of the cookie to be set or inspected.
788 The first parameter sets the name of the cookie to be inserted or inspected.
789 Additional parameters may be as follows: 744 Additional parameters may be as follows:
790 <list type="tag"> 745 <list type="tag">
791 746
792 <tag-name><literal>expires</literal></tag-name> 747 <tag-name><literal>expires</literal></tag-name>
793 <tag-desc> 748 <tag-desc>
794 Sets the time for which a browser should keep the cookie. 749 Sets the time for which a browser should keep the cookie.
795 The parameter <literal>max</literal> will cause the cookie to expire on 750 The special value <literal>max</literal> will cause the cookie to expire on
796 “<literal>31 Dec 2037 23:55:55 GMT</literal>”. 751 “<literal>31 Dec 2037 23:55:55 GMT</literal>”.
797 This is the maximum time understood by old browsers. 752 This is the maximum time understood by old browsers.
798 If the parameter is not specified, it will cause the cookie to expire at 753 If the parameter is not specified, it will cause the cookie to expire at
799 the end of a browser session. 754 the end of a browser session.
800 </tag-desc> 755 </tag-desc>
812 </list> 767 </list>
813 If any parameters are omitted, the corresponding cookie fields are not set. 768 If any parameters are omitted, the corresponding cookie fields are not set.
814 </para> 769 </para>
815 770
816 <para> 771 <para>
772 When the <literal>route</literal> method is used, proxied server assigns
773 client a route on receipt of the first request.
774 All subsequent requests from this client will carry routing information
775 in a cookie or URI.
776 This information is compared with the “<literal>route</literal>” parameter
777 of the <link id="server"/> directive to identify the server to which the
778 request should be proxied.
779 If the designated server cannot process a request, the new server is
780 selected by the configured balancing method as if there is no routing
781 information in the request.
782 </para>
783
784 <para>
785 The parameters of the <literal>route</literal> method specify variables that
786 may contain routing information.
787 The first non-empty variable is used to find the matching server.
788 </para>
789
790 <para>
791 Example:
792 <example>
793 map $cookie_jsessionid $route_cookie {
794 ~.+\.(?P&lt;route>\w+)$ $route;
795 }
796
797 map $request_uri $route_uri {
798 ~jsessionid=.+\.(?P&lt;route>\w+)$ $route;
799 }
800
801 upstream backend {
802 server backend1.example.com route=a;
803 server backend2.example.com route=b;
804
805 sticky route $route_cookie $route_uri;
806 }
807 </example>
808 Here, the route is taken from the “<literal>JSESSIONID</literal>” cookie
809 if present in a request.
810 Otherwise, the route from the URI is used.
811 </para>
812
813 <para>
817 <note> 814 <note>
818 This directive is available as part of our <commercial_version/> only. 815 This directive is available as part of our <commercial_version/> only.
816 </note>
817 </para>
818
819 </directive>
820
821
822 <directive name="sticky_cookie_insert">
823 <syntax><value>name</value>
824 [<literal>expires=</literal><value>time</value>]
825 [<literal>domain=</literal><value>domain</value>]
826 [<literal>path=</literal><value>path</value>]</syntax>
827 <default/>
828 <context>upstream</context>
829
830 <para>
831 This directive is obsolete since version 1.5.7.
832 An equivalent
833 <link id="sticky"/> directive with a new syntax should be used instead:
834 <note>
835 <literal>sticky cookie</literal> <value>name</value>
836 [<literal>expires=</literal><value>time</value>]
837 [<literal>domain=</literal><value>domain</value>]
838 [<literal>path=</literal><value>path</value>];
819 </note> 839 </note>
820 </para> 840 </para>
821 841
822 </directive> 842 </directive>
823 843