首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >Nginx负载均衡后端健康检查(支持HTTP和TCP)

Nginx负载均衡后端健康检查(支持HTTP和TCP)

作者头像
星哥玩云
发布2022-07-26 20:03:55
发布2022-07-26 20:03:55
1.8K0
举报
文章被收录于专栏:开源部署开源部署

前面有一篇文章记录nginx负载均衡后端检查,链接为 https://www.linuxidc.com/Linux/2019-04/158352.htm

但是只包含http健康检查不包含tcp下面安装nginx可以实现http及tcp健康检查

安装

git clone https://github.com/nginx/nginx.git git clone https://github.com/zhouchangxun/ngx_healthcheck_module.git

cd nginx/; git checkout branches/stable-1.12 git apply ../ngx_healthcheck_module/nginx_healthcheck_for_nginx_1.12+.patch

./auto/configure --with-stream --add-module=../ngx_healthcheck_module/ make && make install

git下载nginx及健康检查模板安装nginx

配置http的upstream配置样式如下

upstream www.xxx.net{     server 172.16.90.232:81;     check interval=3000 rise=2 fall=5 timeout=5000 type=http;     check_http_send "GET / HTTP/1.0\r\n\r\n";     check_http_expect_alive http_2xx http_3xx; }

配置tcp的upstream的配置样式如下

upstream device5000{     server 172.16.90.52:5000;     server 172.16.90.53:5000;     check interval=3000 rise=2 fall=5 timeout=5000 default_down=true type=tcp; }

  在主配置文件新加一个location

location /upstream_status{         healthcheck_status html;     }

Web页面访问

http://ip/upstream_status

页面显示如下

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档