nginx 主动健康检查搭建详解(nginx_upstream_check_module)

该文章详细介绍了如何在Nginx1.21版本上下载、安装和配置nginx_upstream_check_module,用于健康检查和负载均衡。作者首先下载模块并应用特定版本的补丁,然后重新配置和编译Nginx,最后展示了配置文件示例,包括设置检查间隔、请求阈值和类型等参数。
摘要由CSDN通过智能技术生成

版本信息
nginx: 1.21

1.下载nginx_upstream_check_module模块

nginx_upstream_check_module-master.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下。在执行

patch -p1 < /usr/local/nginx_upstream_check_module-master/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.1\r\nHost: 127.0.0.1\r\n\r\n";
        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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值