nginx 反向代理负载均衡

1.down 表示单前的server暂时不参与负载  
2.weight 默认为1.weight越大,负载的权重就越大。  
3.max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误  
4.fail_timeout:max_fails次失败后,暂停的时间。  
5.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。 

   upstream web_server {
         server resin1:8080 weight=10 max_fails=3 fail_timeout=2s;
         server resin2:8080 weight=10 max_fails=3 fail_timeout=2s;
         server resin3:8080 weight=10 max_fails=3 fail_timeout=2s;
         keepalive 32;
     }

        server {
          listen       80;
          server_name  www.xxxx.com;
  
              
          location / {
              proxy_next_upstream http_404 http_500 http_502 http_503 http_504 error timeout invalid_header;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header Host  $host;
              proxy_set_header X-Forwarded-For  $remote_addr;
              proxy_read_timeout 10s;
              proxy_pass web_server;
         }    
     }



原文地址:https://www.cnblogs.com/zhenxing06/p/13299361.html