nginx upstream块参数说明

下面是例子

upstream bakend{ #定义负载均衡设备的Ip及设备状态
      ip_hash;
      server 10.0.0.11:9090 down;
      server 10.0.0.11:8080 weight=2;
      server 10.0.0.11:6060 weight=2 max_fails=2 fail_timeout=600s;
      server 10.0.0.11:7070 backup;
}
  1. weight 默认为1.weight越大,负载的权重就越大。

  2. down 表示当前的server暂时不参与负载.

  3. max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误.

  4. fail_timeout : max_fails次失败后,暂停的时间。

  5. backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。不能和 ip_hash 关键字一起使用