nginx_upstream_jvm_route 是一个 Nginx 的扩展模块,用来实现基于 Cookie 的 Session Sticky 的功能。
安装方法(进入Nginx源码目录):
#patch -p0 < /path/to/this/directory/jvm_route.patch
# ./configure --prefix=/usr/nginx-0.8.1 --with-http_stub_status_module --add-module=/path/to/this/directory/
#make
#make install
例如以下配置:
1. Resin:
upstream backend {
server 192.168.0.100 srun_id=a;
server 192.168.0.101 srun_id=b;
server 192.168.0.102 srun_id=c;
server 192.168.0.103 srun_id=d;
jvm_route $cookie_JSESSIONID;
}
2. Tomcat:
upstream backend {
server 192.168.0.100 srun_id=a;
server 192.168.0.101 srun_id=b;
server 192.168.0.102 srun_id=c;
server 192.168.0.103 srun_id=d;
jvm_route $cookie_JSESSIONID reverse;
}
1