nginx负载均衡策略的4种配置

四种负载均衡均衡配置打开配置文件, vim nginx.conf进行修改添加即可

1、轮询模式(默认)

upstream bdp {
      server 192.168.0.101:8080;
      server 192.168.0.102:8080;
      server 192.168.0.103:8080;
    }

2、权重模式

upstream bdpweight {
      server 192.168.0.101:8080 weight=4;
      server 192.168.0.103:8080 weight=1;
      server 192.168.0.102:8080 weight=1;
    }

3、最少连接数

upstream bdpleast {
      least_conn;
      server 192.168.0.101:8080;
      server 192.168.0.103:8080;
      server 192.168.0.102:8080;
    }

4、IpHash

upstream bdphash {
      ip_hash;
      server 192.168.0.101:8080;
      server 192.168.0.103:8080;
      server 192.168.0.102:8080;
    }

你可能感兴趣的:(nginx,nginx,linux)