ubuntu 12.04.4 安装nginx部署session sticky

前端之家收集整理的这篇文章主要介绍了ubuntu 12.04.4 安装nginx部署session sticky前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1,安装依赖的库和包,否则编译会报错

apt-get install gcc libpcre3 libpcre3-dev openssl libssl-dev make

2,下载附件中的Nginx-1.8.1.tar.gz 及Nginx-sticky-module-1.1.tar.gz

备注:

Nginx-sticky-module-1.1模块在附件中,下载附件后,重命名

mv aa.txtNginx-sticky-module-1.1.tar.gz

mv Nginx-1.8.1.txtNginx-1.8.1.tar.gz

tar xfNginx-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,编译安装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

会报错,根据错误提示修改文件(参考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,配置Nginx.conf

cd /usr/local/Nginx-1.8.1/conf

cat Nginx.conf 内容如下:

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,检测语法,启动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




其实session持久化就Nginx本身而言是有三种方式的

cookie

route

learn

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

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

原文链接:https://www.f2er.com/ubuntu/355529.html

猜你在找的Ubuntu相关文章