NGINX+TOMCAT SESSION共享jvmRoute

使用新版的NGINX:nginx-1.4.3
下载jvmRoute
百度网盘:http://pan.baidu.com/s/1GGSW3

安装过程:
1、

cd ./nginx-1.4.3

2、

patch -p0 < /root/nginx-jvm/jvm_route.patch

3、

./configure --prefix=/opt/nginx/ --add-module=/root/nginx-jvm/

4、

make && make install

5、更改NGINX配置文件

upstream backend {
    server 192.168.0.100 srun_id=a;
    server 192.168.0.100 srun_id=b;
    jvm_route $cookie_JSESSIONID reverse;
  }

6、更改TOMCAT1和TOMCAT2

vim conf/server.xml
Tomcat a:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="a">
Tomcat b:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="b">

7、测试页面代码:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<html>
<head>
</head>
<body>
$your_jvm_name
<br />
<%out.print(request.getSession()) ;%> <br />
<%out.println(request.getHeader("Cookie"))&nbsp;%>
</body>
</html>

发表评论

电子邮件地址不会被公开。