NGINX负载配置max_fails和fail_timeout使用问题:
总体配置的情况如下:
server {
listen 8090;
server_name localhost:8090;
location / {
proxy_pass http://springboot;
proxy_read_timeout 30;
}
}
upstream springboot {
server localhost:8080 max_fails=1 fail_timeout=60s;
server localhost:8081 max_fails=1 fail_timeout=60s;
server localhost:8082 max_fails=1 fail_timeout=60s;
}
问题描述:
当前是服务服务返回的状态码是:500,那我们就需要增加判断哪些情况下是失效的:因此增加:
proxy_next_upstream error timeout http_500
不生效,目前后端返回500的状态,不能完成max_fails的,负载到下一台的效果
原因分析:
我也不知道啥原因,
解决方案:
non_idempotent normally, requests with a non-idempotent method (POST, LOCK, PATCH) are not passed to the next server if a request has been sent to an upstream server (1.9.13); enabling this option explicitly allows retrying such requests;
proxy_next_upstream error timeout http_500 non_idempotent
增加了non_idempotent就可以了,目前是高版本支持。