当前位置: 首页 > news >正文

tomcat集成redis实现共享session

中间件:Tomcat、Redis、Nginx

jar包要和tomcat相匹配

jar包:commons-pool2-2.2.jar、jedis-2.5.2.jar、tomcat-redis-session-manage-tomcat7.jar

配置Tomcat

/conf/context.xml

<?xml version='1.0' encoding='utf-8'?>
<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis work for additional information regarding copyright ownership.The ASF licenses this file to You under the Apache License, Version 2.0(the "License"); you may not use this file except in compliance withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context><!-- Default set of monitored resources --><WatchedResource>WEB-INF/web.xml</WatchedResource><!-- Uncomment this to disable session persistence across Tomcat restarts --><!--<Manager pathname="" />--><!-- Uncomment this to enable Comet connection tacking (provides eventson session expiration as well as webapp lifecycle) --><!--<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />--><Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /><Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"host="192.168.2.223"port="6379"       database="3"maxInactiveInterval="60" /></Context>

配置NGINX

nginx.conf


#user  nobody;
worker_processes  1;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;#pid        logs/nginx.pid;events {worker_connections  1024;
}http {include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;upstream nginx-xxxx{server 192.168.2.211:8011;server 192.168.2.211:8021;}server {listen       7013;server_name  localhost;location /{proxy_pass  http://nginx-xxxx/;proxy_redirect default;     proxy_set_header Host $host:$server_port;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 10;proxy_read_timeout 60;proxy_send_timeout 60;}}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

相关文章:

  • AWS S3企业级部署解决方案:从入门到高可用性实践
  • 108. 将有序数组转换为二叉搜索树
  • 诠视科技MR眼镜如何使用头瞄点和UGUI交互
  • Unity-GC详解
  • 机器学习逻辑回归损失函数与正则化技术深度解析
  • 网络协议之详解(Detailed Explanation of Network Protocol)
  • 第33周JavaSpringCloud微服务 面试题
  • 【数据可视化-21】水质安全数据可视化:探索化学物质与水质安全的关联
  • Qt开发:软件崩溃时,如何生成dump文件
  • ffmpeg 硬解码相关知识
  • Spring之我见 - Spring MVC重要组件和基本流程
  • 开启报名!火山引擎 x PICO-全国大学生物联网设计竞赛赛题发布
  • 【MATLAB第117期】#源码分享 | 基于MATLAB的SSM状态空间模型多元时间序列预测方法(多输入单输出)
  • 【随手记】jupyter notebook绘制交互式图像
  • Shell循环语句---for和while
  • 【上海大学数据库原理实验报告】MySQL数据库的C/S模式部署
  • 发送百度地图的定位
  • 物联网蓬勃发展是助力楼宇自控技术迈向成熟的关键
  • AI 健康小屋:开启智慧健康管理新范式
  • # 06_Elastic Stack 从入门到实践(六)
  • 神二十具备执行发射任务的各项条件
  • 洛阳白马寺内的狄仁杰墓挂上公示牌争论尘埃落定?瀍河区文旅局称已确认
  • 南北皆宜的“中国酒都”宿迁:下一程如何更“醇厚绵长”
  • 河南省濮阳市委常委、组织部部长刘建茂接受审查和调查
  • 宇树的任务已经完成?王兴兴也在等待行业拐点
  • 最高法:抢票软件为用户提供不正当优势,构成不正当竞争