@H_404_0@1,安装依赖的库和包,否则编译会报错
@H_404_0@apt-get install gcc libpcre3 libpcre3-dev openssl libssl-dev make
@H_404_0@2,下载附件中的Nginx-1.8.1.tar.gz 及Nginx-sticky-module-1.1.tar.gz
@H_404_0@备注:
@H_404_0@Nginx-sticky-module-1.1模块在附件中,下载附件后,重命名
@H_404_0@mv aa.txtNginx-sticky-module-1.1.tar.gz
@H_404_0@mv Nginx-1.8.1.txtNginx-1.8.1.tar.gz
@H_404_0@tar xfNginx-1.8.1.tar.gz
@H_404_0@mkdir /usr/local/Nginx-sticky-module-1.1/
@H_404_0@tar xf Nginx-sticky-module-1.1.tar.gz -C /usr/local/Nginx-sticky-module-1.1/
@H_404_0@cd Nginx-1.8.1/
@H_404_0@3,编译安装Nginx
@H_404_0@./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
@H_404_0@会报错,根据错误提示修改文件(参考http://tenderrain.blog.51cto.com/9202912/1880880)
@H_404_0@vim /usr/local/Nginx-sticky-module-1.1/Nginx-sticky-module-1.1/ngx_http_sticky_misc.c +281
@H_404_0@make
@H_404_0@make install
@H_404_0@4,配置Nginx.conf
@H_404_0@cd /usr/local/Nginx-1.8.1/conf
@H_404_0@cat Nginx.conf 内容如下:
@H_404_0@worker_processes 5;
@H_404_0@events {
@H_404_0@ worker_connections 1024;
@H_404_0@}
@H_404_0@http {
@H_404_0@ include mime.types;
@H_404_0@ default_type application/octet-stream;
@H_404_0@ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
@H_404_0@ '$status $body_bytes_sent "$http_referer" '
@H_404_0@ '"$http_user_agent" "$http_x_forwarded_for"';
@H_404_0@ sendfile on;
@H_404_0@ keepalive_timeout 65;
@H_404_0@ map $cookie_jsessionid $route_cookie {
@H_404_0@ ~.+\.(?P<route>\w+)$ $route;
@H_404_0@ }
@H_404_0@ map $request_uri $route_uri {
@H_404_0@ ~jsessionid=.+\.(?P<route>\w+)$ $route;
@H_404_0@ }
@H_404_0@ upstream jiracluster {
@H_404_0@ server 10.32.115.91:8090;
@H_404_0@ server 10.32.115.92:8090;
@H_404_0@ sticky;
@H_404_0@ }
@H_404_0@
@H_404_0@
@H_404_0@server {
@H_404_0@ listen 80;
@H_404_0@ server_name 10.32.116.28;
@H_404_0@ location / {
@H_404_0@ proxy_set_header Host $host;
@H_404_0@ proxy_set_header X-Real-IP $remote_addr;
@H_404_0@ proxy_pass http://jiracluster;
@H_404_0@ }
@H_404_0@
@H_404_0@ error_log /tmp/error.log;
@H_404_0@ access_log /tmp/access.log;
@H_404_0@ }
@H_404_0@
@H_404_0@
@H_404_0@}
@H_404_0@5,检测语法,启动Nginx
@H_404_0@/usr/local/Nginx-1.8.1/sbin/Nginx -t
@H_404_0@/usr/local/Nginx-1.8.1/sbin/Nginx
@H_404_0@/usr/local/Nginx-1.8.1/sbin/Nginx -t
@H_404_0@/usr/local/Nginx-1.8.1/sbin/Nginx -s reload
@H_404_0@
@H_404_0@
@H_404_0@
@H_404_0@其实session持久化就Nginx本身而言是有三种方式的
@H_404_0@cookie
@H_404_0@route
@H_404_0@learn
@H_404_0@http://nginx.org/en/docs/http/ngx_http_upstream_module.html
@H_404_0@http://blog.csdn.net/agangdi/article/details/41087921