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

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;#    }#}}

http://www.xdnf.cn/news/1078.html

相关文章:

  • 文件上传漏洞3
  • 路由与路由器
  • Centos虚拟机远程连接缓慢
  • Docker 与 Docker-Compose 的区别
  • AI数字人:元宇宙舞台上的闪耀新星(7/10)
  • go-Casbin使用
  • docker-compose搭建kafka
  • 【MCP Node.js SDK 全栈进阶指南】中级篇(1):MCP动态服务器高级应用
  • 2025智能驾驶趋势评估
  • FreeRTOS【1】如何设置keil的软件仿真
  • GTS-400 系列运动控制器板(九)----设置轴为闭环控制方式
  • Ansys Zemax | 在 MATLAB 中使用 ZOS-API 的技巧
  • 【go】简单理解梳理go的内存分配原理
  • Nginx​中间件的解析
  • 蓝桥杯 19.合根植物
  • 逻辑回归:损失和正则化技术的深入研究
  • 音频base64
  • 三角形神经网络(TNN)
  • 豪越科技消防公车管理系统:智能化保障应急救援效率
  • LeetCode 1292 元素和小于等于阈值的正方形的最大边长
  • 洗车小程序系统前端uniapp 后台thinkphp
  • Sharding-JDBC 系列专题 - 第五篇:分布式事务
  • Linux 系统监控大师:Glances 工具详解助力自动化
  • 【DeepSeek 学习推理】Llumnix: Dynamic Scheduling for Large Language Model Serving
  • 从代码学习深度学习 - 异步计算 PyTorch 版
  • 【音视频】FFmpeg解封装
  • (8)ECMAScript语法详解
  • 【Git】Git Revert 命令详解
  • C语言高频面试题——malloc 和 calloc区别
  • 今日CSS笔记