版本信息
nginx: 1.21

1.下载nginx_upstream_check_module模块

nginx_upstream_check_modulemaster.zip

wget https://codeload.github.com/yaoweibin/nginx_upstream_check_module/zip/master

解压

2. 安装nginx

3. 补丁安装

由于我这边安装nginx版本nginx1.21版本。所以选择补丁版本check_1.20.1+.patch

注意:由于我这边nginx_upstream_check_module自己创建文件路径。所以需要移动

/usr/local下。在执行

patchp1 < /usr/local/nginx_upstream_check_modulemaster/check_1.20.1+.patch

相关文章: 【Linux】关于patch命令中参数P的说明_cannot find file to patch_Mr_EvanChen的博客-CSDN博客

4: 重新配置nginx

./configure--add-module=/usr/local/nginx_upstream_check_module-master
make && make install

5:配置nginx

upstream lunxun2{
        server 127.0.0.1:9595;
        server 127.0.0.1:8081;
        #对name这个负载均衡条目中的所有节点每个3秒检测一次请求2次正常则标记 realserver状态up
        #如果检测 5 次都失败,则标记 realserver状态down超时时间为1秒
        check interval=10000 rise=2 fall=5 timeout=1000 type=http;
        check_http_send “GET /test/test HTTP/1.1rnHost: 127.0.0.1rnrn”;
        check_http_expect_alive http_2xx http_3xx;
    }

特别注意:  type=http最好改为tcp
 
    #检查状态,可在浏览器访问http://xxxx/nstatus
    location /nstatus {
       check_status;
       access_log off;
       #allow IP;
       #deny all;
    }
参考资料http://www.jdccie.com/?p=3566

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注