nginx怎么配置upstream

2026-02-14 09:17:37

1、打开nginx.conf。

下面教大家upstream五种负载均衡配置。

nginx怎么配置upstream

2、upstream负载均衡配置如下图。

默认是轮询:每个请求逐一分配到后端服务器,如果服务器宕掉了自动剔除。

nginx怎么配置upstream

3、weight按权重配置(如图): 权重越高的后端,分配到请求越多。

nginx怎么配置upstream

4、ip_hash(按地址哈希分配):每个请求按访问ip的hash结果分配。

nginx怎么配置upstream

5、按后端服务器的响应时间来分配请求,响应时间短的优先分配。

nginx怎么配置upstream

6、按访问url的hash结果来分配请求。

nginx怎么配置upstream

7、配置详解:

1.down表示server暂时不参与负载

2. weight为weight越大,负载的权重就越大。

3. max_fails:允许请求失败的次数默认为1

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

5.backup:作为备份服务。

nginx怎么配置upstream

相关推荐
  • 阅读量:158
  • 阅读量:162
  • 阅读量:40
  • 阅读量:178
  • 阅读量:131
  • 猜你喜欢