注册 登录  
 加关注

网易博客网站关停、迁移的公告:

将从2018年11月30日00:00起正式停止网易博客运营
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

老和山小和尚

敬天爱人

 
 
 

日志

 
 
 
 

nginx upstream session sticky模块发布  

2009-07-14 13:06:47|  分类: Nginx |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

download:http://code.google.com/p/nginx-upstream-jvm-route/

nginx_upstream_jvm_route
-------

This module achieves session stickiness with the session cookie. If the session is not in the cookie or URL, the module will be a normal Round-Robin upstream module.

INSTALLATION

cd nginx-0.7.59 # or whatever
patch -p0 < /path/to/this/directory/jvm_route.patch

compile nginx with the following addition option:

--add-module=/path/to/this/directory

EXAMPLE

1.For 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|sessionid;
}
2.For 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|sessionid reverse;
}

DIRECTIVES

jvm_route

syntax: jvm_route $cookie_SESSION_COOKIE[|session_url] [reverse]
default: none
context: upstream
description:
'$cookie_SESSION_COOKIE' specifies the session cookie name(0.7.24+). 'session_url' specifies a different session name in the URL when the client does not accept a cookie. The session name is case-insensitive. In this module, if it does not find the session_url, it will use the session cookie name instead. So if the session name in cookie is the name with its in URL, you don't need give the session_url name.
With scanning this cookie, the module will send the request to right backend server. As far as I know, the resin's srun_id name is in the head of cookie. For example, requests with cookie value 'a***' are always sent to the server with the srun_id of 'a'. But tomcat's JSESSIONID is opposite, which is like '***.a'. The parameter of 'reverse' specifies the cookie scanned from tail to head.
If the request fails to be sent to the chosen backend server, It will try another server with the Round-Robin mode until all the upstream servers tried. The directive proxy_next_upstream can specify in what cases the request will be transmitted to the next server. If you want to force the session sticky, you can set 'proxy_next_upstream off'.

server

Every syntax is the same with the official directive except the parameter of 'srun_id' which identified the backend JVM's name by cookie. The default srun_id's value is 'a';


Note: This is a third-party module. And you need careful test before using this module in your product environment.

Questions/patches may be directed to Weibin Yao, yaoweibin@gmail.com.

  评论这张
 
阅读(2386)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018