nginx安装nginx_upstream_check_module模块
转载自:https://blog.51cto.com/riverxyz/3928890
背景
tengin的nginx_upstream_check_module模块具有心跳检测功能,当发现某个节点不能访问的时候自动切换到另外一个节点,可惜这不是nginx官方自带的模块,需要自己编译
下载nginx
http://nginx.org/en/download.html
下载的地址是:https://nginx.org/download/nginx-1.22.1.tar.gz
下载模块
https://github.com/yaoweibin/nginx_upstream_check_module
https://github.com/yaoweibin/nginx_upstream_check_module/tags
https://github.com/yaoweibin/nginx_upstream_check_module/releases/tag/v0.4.0
从tag中下载:https://github.com/yaoweibin/nginx_upstream_check_module/archive/refs/tags/v0.4.0.zip
注意下载模块适用的nginx版本
进行安装Nginx和编译
tar -zxv -f nginx-1.22.1.tar.gz
unzip nginx_upstream_check_module-0.4.0.zip (从模块tag中下载后的文件名)
cd /usr/local/src/nginx-1.22.1
yum -y install patch
patch -p1 < /usr/local/src/nginx_upstream_check_module-0.4.0/check_1.20.1+.patch #这步很重要,打补丁
./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/nginx_upstream_check_module-0.4.0 #加载模块使用绝对路径
make
make install
编辑配置文件
# vim /usr/local/nginx/conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream cluster {
server 127.0.0.1:80;
server 127.0.0.1:5040;
check interval=3000 rise=2 fall=5 timeout=1000 type=http;
check_http_send "HEAD / HTTP/1.0\r\n\r\n";
check_http_expect_alive http_2xx http_3xx;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://cluster;
}
location /status {
check_status;
access_log off;
}
}
}
启动并验证
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
浏览器访问
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
2022-02-28 关于使用kuboard安装其自带的监控应用授权普通用户使用
2022-02-28 关于使用kuboard安装其自带的监控应用的注意事项
2022-02-28 在 AlertManager 报警通知中展示监控图表
2019-02-28 Python高效编程技巧