PythonIED

Nginx 健康节点检查

2020-01-10  本文已影响0人  平凡的运维之路

下载对应nginx和nginx_upstream_check版本

wget 'http://nginx.org/download/nginx-1.14.2.tar.gz'

https://github.com/yaoweibin/nginx_upstream_check_module  #github地址

解压进去nginx源代码目录,然后给Nginx打补丁文件

cd nginx-1.14.2
patch -p1 < ../nginx_upstream_check_module-master/check_1.14.0+.patch

编译安装

./configure --add-module=/root/nginx_upstream_check_module-master && make -j 8 && make install

指令解释

    http {

        upstream cluster {

            # simple round-robin
            server 192.168.0.1:80;
            server 192.168.0.2:80;

            check interval=5000 rise=1 fall=3 timeout=4000;# 每5s向后台健康检查,连续成功数达到1则为up,连续失败数达到fall,则后台服务器为down,超时时间为4s。
        }

        server {
            listen 80;

            location / {
                proxy_pass http://cluster;
            }

            location /nstatus {
                check_status;

                access_log   off;
                allow SOME.IP.ADD.RESS;
                deny all;
           }
        }

    }
    
上一篇 下一篇

猜你喜欢

热点阅读