Session共享

  1.Nginx通过负载均衡IP地址固定绑定,解决Session共享

upstream backserver { 
    ip_hash;
    server 127.0.0.1:8080; 
    server 127.0.0.1:8090;
}

server {
    isten       80;
    server_name  www.wdksoft.com;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
                    
    proxy_pass http://backserver;
    index index.html index.htm;
                    
    }
}

  2.Spring-session+Redis解决Session共享
    2.1 保证Redis启动
    2.2 导入依赖


                
                    org.springframework.boot
                    spring-boot-starter-redis
                 
                
                    org.springframework.session
                    spring-session-data-redis
                
            

    2.3 配置大配置文件

server:
     port: 8090

    #redis配置
    spring:
        redis:
        password: redis

你可能感兴趣的:(Session共享)