基于nginx+redis+tomcat 实现session 共享
1、安装好多个tomcat,并安装好redis,在apache-tomcat-7.0.75\lib 目录下添加如下这三个包http://s1.运维网.com/images/20180925/1537845606637183.png
2、修改apache-tomcat-7.0.75\conf\context.xml
WEB-INF/web.xml
其中192.168.1.111为自己的redis 服务器IP
3、在apache-tomcat-7.0.75_02\webapps\ROOT 下写一个测试界面index.jsp
Insert title here
您现在访问的是9999服务器,用户名为:${username}
注:9999为该台tomcat服务器端,测试时不同服务器修改成不一样的
4、安装好nginx 修改nginx.conf 加入如下配置
http://s1.运维网.com/images/20180925/1537846036911475.png
server 配置多个
http://s1.运维网.com/images/20180925/1537846094573983.png
5、先启动redis,再启动tomcat,最后启动nginx,在浏览器中访问http://localhost/
http://s1.运维网.com/images/20180925/1537846283508069.png
此时输入admin 点提交,多次涮新,可以看到不管跳到8080,还是9999,服务器的session 都可以获取到
http://s1.运维网.com/images/20180925/1537846342155233.png
http://s1.运维网.com/images/20180925/1537846382947317.png
页:
[1]