Nginx Session Sticky

Source: Internet
Author: User

Nginx Sticky session is mainly realized by Nginx-sticky-module

1 downloads nginx-sticky-module

: https://code.google.com/p/nginx-sticky-module/downloads/list

Official Document: Https://code.google.com/p/nginx-sticky-module/wiki/Documentation

2 installation

Unzip Nginx-sticky-module to/usr/local

Tar-xzf nginx-sticky-module-1.1.tar.gz

Enter the Nginx source directory/usr/local/nginx-1.6.2, execute the command, recompile:

./configure.--add-module=. /nginx-sticky-module-1.1makemake Install

3 Make Error

The following error may occur due to a high version of Make:

MAKE[1]: * * * [OBJS/ADDON/NGINX-STICKY-MODULE-1.1/NGX_HTTP_STICKY_MISC.O] Error 1make[1]: Leaving directory '/usr/ local/nginx-1.6.2 ' Make: * * * [build] Error 2

Workaround:

The 281 lines of NGINX-STICKY-MODULE-1.1/NGX_HTTP_STICKY_MISC.C are modified to:

Digest->len = Ngx_sock_ntop (in,sizeof (struct sockaddr_in), Digest->data, Len, 1);

4 Sticky Use

Upstream 172.16.0.16 {        sticky;        Server 172.16.0.17:8180;        Server 172.16.0.17:8280;        Server 172.16.0.18:8180;        Server 172.16.0.18:8280;    }

Sticky supported parameters:sticky [Name=route] [Domain=.foo.bar] [path=/] [expires=1h] [HASH=INDEX|MD5|SHA1] [ no_fallback];

Name: can be any string character, default is routedomain: which domain name can be used under this cookiepath: which path to enable sticky, for example path/test, Then only test this directory will use sticky do load balancing Expires:cookie expiration time, the default browser close expires, that is, session mode. No_fallbackup: If this is set, the server of the cookie is down, then it will return 502 (Bad gateway or proxy error), it is recommended not to be enabled.

As follows:

Sticky Name=routeid expires=1h domain=.test.com path=/;

Nginx Session Sticky

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.