Spring Boot + Redis + Nginx 如何实现两个不同项目(非同一项目多次部署)的session共享?

现有两台服务器,每台服务器上都要分别部署ProjectA和ProjectB两个项目,两个项目的用户登陆模块几乎一致,想通过spring boot + redis + nginx实现跨项目的session共享及负载均衡(四个项目session共享),两个项目redis配置一样,如下

spring.redis.port=6379
spring.redis.host=192.168.1.8
spring.redis.password=123456
spring.redis.pool.max-active=100
spring.redis.pool.max-idle=5
spring.redis.pool.max-wait=60000
spring.session.store-type=redis

nginx.conf主要配置如下

upstream steamA{
ip_hash;
server 192.168.1.11:8080;
server 192.168.1.12:8080;
}
upstream streamB{
ip_hash;
server 192.168.1.11:8075;
server 192.168.1.12:8075;
}
server {
    listen       80;
    server_name  localhost;

    charset utf-8;

    access_log  logs/host.access.log;

 location /ProjectA/ {
    proxy_pass http://steamA/ProjectA/;
    proxy_redirect off;
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    index Login.html;
    }

 location /ProjectB/ {
    proxy_pass http://streamB/ProjectB/;
    proxy_redirect off;
    proxy_set_header Host $host:$server_port;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    index Login.html;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

这样的配置,两个A项目能共享session,两个B项目也能共享session,但A和B不能共享session,问下大神们需要如何处理?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐