1. 程式人生 > >nginx 健康檢查 打補丁upstream_check_module

nginx 健康檢查 打補丁upstream_check_module

環境:Centos7 專案描述:已安裝nginx-1.12.2版本,在原有服務的基礎上打個補丁upstream_check_module,

步驟

2、還是在 nginx-1.12.0 資料夾下 patch -p1 < /root/nginx_upstream_check_module-master/check_1.12.1+.patch

3、編譯,還是在 nginx-1.12.0 資料夾下 ./configure --add-module=/root/nginx_upstream_check_module-master

make && make install

4、修改配置檔案

vim /usr/local/nginx/conf/nginx.conf upstream backend {

    server  192.168.4.2:8080;

    server  192.168.4.3:8080;

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

}

server {

    listen      80;

    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {

  #    root  html;

  #    index  index.html index.htm;

        proxy_pass  http://backend;

    }

    location /nstatus {

      check_status;

      access_log off;

    }

#error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html

    #

    error_page  500 502 503 504  /50x.html;

    location = /50x.html {

        root  html;

    }

5、重新載入 nginx -s reload

6、客戶端訪問

從上圖可以看出 現在有兩個節點 我們人為把其中57.85節點API關閉,此時狀態為down 節點正常時會恢復為正常狀態