zoukankan      html  css  js  c++  java
  • nginx nginx_upstream_check_module自动踢除后端机器

    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
    
    ";
                #check_http_expect_alive http_2xx http_3xx;
            }
    
            server {
                listen 80;
    
                location / {
                    proxy_pass http://cluster;
                }
    
                location /check_status {
                    check_status;
    
                    access_log   off;
                    allow SOME.IP.ADD.RESS;
                    deny all;
               }
            }
    
        }
    

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

  • 相关阅读:
    springboot 搭建druid数据监控
    spring-boot编写简易mvc
    解决rabbitmq 开启启动报错
    intelij idea 使用maven打包报错 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1
    php foreach循环引用的问题
    手把手编写hyperf JsonRpc demo
    centos8配置nfs教程本机系统mac
    Java基础的练习题
    Java——循环
    Java——数组
  • 原文地址:https://www.cnblogs.com/Qing-840/p/11490456.html
Copyright © 2011-2022 走看看