nginx负载均衡session共享解决:ip_hash

    声明:此方法只适用于nginx不是最前端的服务器,并且nginx的后端没有其它方式的负载均衡前端

    只须要在nginx.conf的负载配置中加上一行 ip_hash;nginx

例:后端

 upstream tomcat_server{
        server localhost:8080 weight=1;
        server localhost:8081 weight=2;
        ip_hash;
    }
 tomcat