架构如下:

当时servera的容器oom了,开始不停重启,造成80端口是活着的,但没法正常提供http服务
原先的配置如下:
upstream aaa {
server 192.168.31.17;
server 192.168.31.27;
}
server {
listen 192.168.31.67:80;
server_name aa.qiuqin.com 192.168.31.67;
location / {
proxy_pass http://aaa;
}
}
https://github.com/yaoweibin/nginx_upstream_check_module

https://nginx.org/en/download.html

yum install -y gcc‐c++ pcre pcre‐devel zlib zlib‐devel openssl openssl‐devel patch pcre-devel zlib unzip
mkdir -p /apps/install/
cd /apps/install/
unzip nginx_upstream_check_module-master.zip
tar xf nginx-1.20.2.tar.gz
cd /apps/install/nginx-1.20.2
patch -p1 < /apps/install/nginx_upstream_check_module-master/check_1.20.1+.patch
由于是测试环境新装就直接configure了
./configure --with-http_stub_status_module \
--add-module=/apps/install/nginx_upstream_check_module-master
make -j 4 && make install
ln -sf /usr/local/nginx/sbin/nginx /usr/bin/nginx
如果是原来的升级先执行
nginx -V
把原来的配置复制出来,再追加–with-http_stub_status_module --add-module=/apps/install/nginx_upstream_check_module-master
我单独配置了个conf,也可以直接写在nginx.conf里
/usr/local/nginx/conf/conf.d/aa.conf
| 参数 | 含义 |
|---|---|
| interval | 检测间隔时间,单位为毫秒 |
| rsie | 请求2次正常的话,标记此realserver的状态为up |
| fall | 表示请求5次都失败的情况下,标记此realserver的状态为down |
| timeout | 为超时时间,单位为毫秒。 |
upstream aaa {
server 192.168.31.17;
server 192.168.31.27;
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;
}
server {
listen 192.168.31.67:80;
server_name aa.qiuqin.com 192.168.31.67;
location / {
proxy_pass http://aaa;
}
}
两台web都正常启动

关闭27的nginx,并启动80的监听

此时27上80端口可以被telnet到,但nginx已经不会再转发请求了
