nginx :上游返回失败时的处理办法

前提:上游服务器没有向客户端发送任何内容

1.proxy_next_upstream 指令(当出现错误时,nginx为其重新分配上游服务器)

   语法:proxy_next_upstream  error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | http_ 429 | non_idempotent | off ...

   默认:proxy_next_upstream error timeout;

   放置位置:http,server,location

配置 
   error :nginx与上游建立连接,读取响应,发送请求,等等网络错误都可以满足场景

   timeout:超时

   invalid_header:收到的上游http_header不合法

   http_ :明确的响应code。

   non_idempotent :不能重选新服务时。

   off:关闭功能

2.proxy_next_upstream_timeout 指令(限制proxy_next_upstream的时间)

   语法:proxy_next_upstream_timeout   time;

   默认:proxy_next_upstream_timeout  0;(0:不限制)

   放置位置:http,server,location

 

3.proxy_next_upstream_tries 指令(限制proxy_next_upstream的次数)

   语法:proxy_next_upstream_tries  number;

   默认:proxy_next_upstream_tries  0;(0:不限制)

   放置位置:http,server,location

4.proxy_intercept_errors  指令(当上游响应的响应码大于等于300时,应将响应返回客户端还是按error_page指令处理)

   语法:proxy_intercept_errors  on | off

   默认:proxy_intercept_errors  off;

   放置位置:http,server,location

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值