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

栏目: 服务器 · Nginx · 发布时间: 5年前

内容简介:前面有一篇文章记录nginx负载均衡后端检查,链接为但是只包含http健康检查不包含tcp下面安装nginx可以实现http及tcp健康检查git clone https://github.com/nginx/nginx.git

前面有一篇文章记录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

页面显示如下

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

下面关于 Nginx 的文章您也可能喜欢,不妨参考下:

CentOS 7下Nginx服务器的安装配置  https://www.linuxidc.com/Linux/2017-04/142986.htm

CentOS上安装Nginx服务器实现虚拟主机和域名重定向  https://www.linuxidc.com/Linux/2017-04/142642.htm

CentOS 6.8 安装LNMP环境(Linux+Nginx+MySQL+PHP)  https://www.linuxidc.com/Linux/2017-04/142880.htm

Linux下安装 PHP 环境并配置Nginx支持php-fpm模块  https://www.linuxidc.com/Linux/2017-05/144333.htm

Nginx服务的SSL认证和htpasswd认证  https://www.linuxidc.com/Linux/2017-04/142478.htm

Ubuntu 16.04上启用加密安全的Nginx Web服务器  https://www.linuxidc.com/Linux/2017-07/145522.htm

Linux中安装配置Nginx及参数详解  https://www.linuxidc.com/Linux/2017-05/143853.htm

Nginx日志过滤 使用ngx_log_if不记录特定日志 https://www.linuxidc.com/Linux/2014-07/104686.htm

CentOS 7.2下Nginx+PHP+MySQL+Memcache缓存服务器安装配置  https://www.linuxidc.com/Linux/2017-03/142168.htm

Nginx反向代理实现Tomcat负载均衡 https://www.linuxidc.com/Linux/2018-03/151223.htm

Nginx的正向代理与反向代理详解 https://www.linuxidc.com/Linux/2019-03/157360.htm

Nginx搭建反向代理服务器 https://www.linuxidc.com/Linux/2018-03/151418.htm

Nginx 的详细介绍 请点这里

Nginx 的下载地址 请点这里

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址: https://www.linuxidc.com/Linux/2019-04/158358.htm


以上所述就是小编给大家介绍的《Nginx负载均衡后端健康检查(支持HTTP和TCP)》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Convergence Culture

Convergence Culture

Henry Jenkins / NYU Press / 2006-08-01 / USD 30.00

"Convergence Culture" maps a new territory: where old and new media intersect, where grassroots and corporate media collide, where the power of the media producer, and the power of the consumer intera......一起来看看 《Convergence Culture》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具