本文使用的版本:Tengine-2.3.3
在 Tengine 2.3.3 中 ngx_http_upstream_check_module 默认是不包含的,所以编译配置的时候需要手动添加上去
./configure --add-module=modules/ngx_http_upstream_check_module
make
make 过后就可以在 objs 目录下找到 nginx 文件
check
upstream cluster1 {
# simple round-robin
server 192.168.0.1:80;
server 192.168.0.2:80;
check interval=3000 rise=2 fall=5 timeout=1000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
upstream cluster2 {
# simple round-robin
server 192.168.0.3:80;
server 192.168.0.4:80;
check interval=3000 rise=2 fall=5 timeout=1000 type=http;
check_keepalive_requests 100;
check_http_send "HEAD / HTTP/1.1\r\nConnection: keep-alive\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
该模块生效范围是 upstream 中,上面的配置文件就是 每3s检查一次,5次失败->down 2次成功->up down后不再转发请求
check_status
server {
listen 80;
location /1 {
proxy_pass http://cluster1;
}
location /status {
check_status;
}
}
通过 check_status 命令显示服务器的健康状态页面,支持的格式有: html、csv、 json。默认类型是html。
/status?format=html
/status?format=csv
/status?format=json
标签:status,http,module,server,upstream,check
From: https://www.cnblogs.com/manastudent/p/16938123.html