Ubuntu 12.04.4 installation Nginx deployment session sticky

Source: Internet
Author: User

1, install dependent libraries and packages, or compile will error

Apt-get install gcc libpcre3 libpcre3-dev OpenSSL libssl-dev make

2, download nginx-1.8.1.tar.gz and nginx-sticky-module-1.1.tar.gz in the attachment

Note:

nginx-sticky-module-1.1 module in the attachment, after downloading the attachment, rename the

MV Aa.txt nginx-sticky-module-1.1.tar.gz

MV Nginx-1.8.1.txt nginx-1.8.1.tar.gz

Tar XF nginx-1.8.1.tar.gz

Mkdir/usr/local/nginx-sticky-module-1.1/

Tar XF nginx-sticky-module-1.1.tar.gz-c/USR/LOCAL/NGINX-STICKY-MODULE-1.1/

CD NGINX-1.8.1/

3, compile and install Nginx

./configure--prefix=/usr/local/nginx-1.8.1--with-http_stub_status_module--with-http_ssl_module--with-http_ Realip_module--add-module=/usr/local/nginx-sticky-module-1.1/nginx-sticky-module-1.1

Will error, modify the file according to the errors (refer to http://tenderrain.blog.51cto.com/9202912/1880880)

VIM/USR/LOCAL/NGINX-STICKY-MODULE-1.1/NGINX-STICKY-MODULE-1.1/NGX_HTTP_STICKY_MISC.C +281

Make

Make install

4, Configuration nginx.conf

Cd/usr/local/nginx-1.8.1/conf

The cat nginx.conf content is as follows:

Worker_processes 5;

Events {

Worker_connections 1024;

}

HTTP {

Include Mime.types;

Default_type Application/octet-stream;

Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '

' $status $body _bytes_sent ' $http _referer '

' "$http _user_agent" "$http _x_forwarded_for";

Sendfile on;

Keepalive_timeout 65;

Map $cookie _jsessionid $route _cookie {

~.+\. (? p<route>\w+) $ $route;

}

Map $request _uri $route _uri {

~jsessionid=.+\. (? p<route>\w+) $ $route;

}

Upstream Jiracluster {

Server 10.32.115.91:8090;

Server 10.32.115.92:8090;

Sticky

}



server {

Listen 80;

server_name 10.32.116.28;

Location/{

Proxy_set_header Host $host;

Proxy_set_header X-real-ip $remote _addr;

Proxy_pass Http://jiracluster;

}


Error_log/tmp/error.log;

Access_log/tmp/access.log;

}



}

5, detect syntax, start Nginx

/usr/local/nginx-1.8.1/sbin/nginx-t

/usr/local/nginx-1.8.1/sbin/nginx

/usr/local/nginx-1.8.1/sbin/nginx-t

/usr/local/nginx-1.8.1/sbin/nginx-s Reload




In fact, the session persistence in the Nginx itself is three ways

Cookies

Route

Learn

Http://nginx.org/en/docs/http/ngx_http_upstream_module.html

http://blog.csdn.net/agangdi/article/details/41087921

Ubuntu 12.04.4 installation Nginx deployment 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.