健康检测
TCP心跳检查
upstream backend {
server 192.168.61.1:9080 weight=1;
server 192.168.61.1:9090 weight=2;
check interval=3000 rise=1 fall=3 timeout=2000 type=tcp;
}
interval
:检测间隔时间
fall
:检测失败多少次后,后端服务器标识为不存活
rise
:检测成功多少次后,后端服务器标识为存活
timeout
:检测请求超时时间配置
HTTP心跳检测
upstream backend {
server 192.168.61.1:9080 weight=1;
server 192.168.61.1:9090 weight=2;
check interval=3000 rise=1 fall=3 timeout=2000 type=http;
check_http_send "HEAD /status HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
check_http_send
:检查时发的HTTP
请求内容
check_http_expect_alive
:后端服务器返回匹配响应状态码,则认为后端服务器存活