nginx nginx_upstream_check_module-master 自动踢除

nginx 1.14.0

描述:

nginx自带的upstream配置,如果后端挂了,接口会慢,原因不讲述,故接入第三方的自动检测与自动踢除模式

nginx_upstream_check_module模块:

*** 下载地址https://github.com/yaoweibin/nginx_upstream_check_module ***


 wget 'http://nginx.org/download/nginx-1.14.0.tar.gz'
 tar -xzvf nginx-1.14.0.tar.gz
 cd nginx-1.14.0/
 patch -p1 < /path/to/nginx_http_upstream_check_module/check_1.14.0+.patch


#./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=/opt/tools/openssl-1.0.2l/ --with-pcre-jit --with-ld-opt=-ljemalloc --with-debug --add-module=/opt/tools/nginx-module-vts-master/ --add-module=/opt/tools/nginx_upstream_check_module-master/ --add-module=/opt/tools/ngx_cache_purge-2.3/

#make

#mv objs/nginx /usr/local/nginx/sbin/nginx
#nginx -s reload

nginx配置例子

    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;

            #check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;

            #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 80;

            location / {
                proxy_pass http://cluster;
            }

            location /status {
                check_status;

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

    }

curl http://qing.xxxx/check_status?format=json

上一篇:关于 Nginx upstream keepalive 的说明


下一篇:nginx 均衡分配负载 搭配