nginx的tcp负载均衡如何使用hash算法

配置文件如下

stream  
     { 
     upstream app  
              { 
              hash $remote_addr consistent;
              server 127.0.0.1:8888 weight=5 max_fails=3 fail_timeout=30s;
              server 127.0.0.1:6666 weight=5 max_fails=3 fail_timeout=30s;
       } 
  server  
       { 
         listen 2021;
         proxy_connect_timeout 1s;
         proxy_timeout 3s;
         proxy_pass app;
      }
} 

发表评论

后才能评论