NGINX心跳检测

NGINX心跳检测

upstream springboot {

    server 10.3.73.223:8080 max_fails=2 fail_timeout=30s;

    server 10.3.73.223:8090 max_fails=2 fail_timeout=30s;

}

 

server {

    listen       80;

    server_name  localhost;

 

    location /test {

        proxy_pass http://springboot;

    }

}

  

在30s内(fail_timeout,默认值为10s),NGINX与中间件通讯失败2次(max_fails,默认值为1,设置为0则认为服务端一直可用),则认为中间件不可用

不可用中间件在30s内与NGINX通讯成功2次,则认为中间件恢复。

当upstream中的一台中间件响应失败时, Nginx会将请求转发给下一台中间件,直到所有的中间件都发送过该请求,如果此时依然无法获得成功的响应,客户端将收到最后一台中间件返回的响应结果。

原文地址:https://www.cnblogs.com/hnxxcxg/p/11803523.html