Nginx 安装 nginx_upstream_check_module 模块

Nginx 安装 nginx_upstream_check_module 模块

  1. nginx_upstream_check_module 源码地址(含与 Nginx 的依赖关系)
  2. nginx_upstream_check_module 下载地址

nginx_upstream_check_module 与 Nginx 的关系图。我的 Nginx 是 1.23.1 版本,所以需要用 check_1.20.1+.patch 版本
在这里插入图片描述

进入你的 nginx 源码目录(有 configure 可执行文件的目录),我的在 /usr/local 目录下,将下载的 nginx_upstream_check_module-master.zip 放到 Nginx 源码目录。

cd /usr/local/nginx-1.23.1
// nginx_upstream_check_module-master.zip 包放到 /usr/local/nginx-1.23.1 目录中并解压
unzip nginx_upstream_check_module-master.zip
patch -p1 < nginx_upstream_check_module-master/check_1.20.1+.patch

/*
如果你的 Nginx 安装的时候也安装了 stream、stream_ssl_module、http_ssl_module 这三个模块,且只有这三个模块,那么下面这个命令无脑执行就行。除了 --prefix= 参数配置的路径可以按自己喜好修改,其他的就直接给我无脑粘贴执行。
如果你的 Nginx 不止安装了 stream、stream_ssl_module、http_ssl_module 这三个模块,那么你就继续加入你装的其他模块,你要不是加入那么你以前安装的模块都会被移除。
*/
./configure --prefix=/usr/local/nginx --with-stream --with-stream_ssl_module --with-http_ssl_module --add-module=nginx_upstream_check_module-master

// ===================> start 释义 <===================
--prefix:指定安装目录。
--with-stream:加入 stream 模块。
--with-stream_ssl_module:加入 stream 模块下的 ssl 子模块。
--with-http_ssl_module:加入 http 模块下的 ssl 子模块。
--add-module=nginx_upstream_check_module-master:安装 nginx_upstream_check_module-master 模块。
请注意,这里指定的是 /usr/local/nginx 作为安装目录。
// ===================> end 释义 <===================

// 编译及安装
make && make install

// 查看版本及配置
nginx -V

查看版本及配置效果图

在这里插入图片描述

/usr/local/nginx-1.23.1 是我 Nginx 源码目录,但我在编译安装过程中,使用 --prefix 参数将 Nginx 安装到了 /usr/local/nginx 目录。进入 /usr/local/nginx

cd /usr/local/nginx

// 编辑 nginx.conf 文件
vim /config/nginx.conf

// 在 http 块中配置加入配置
upstream cluster1 {
     # simple round-robin
     server 10.0.1.161:8086;
     server 10.0.1.161:8087;
     check interval=4000 rise=3 fall=5 timeout=3000 type=http;
     }
// 在 http 块中 server 块下加入配置:
//这里 location /1 是什么鬼???别问,就单纯取个名字而已,随便你取什么名字 location /1 也好 location /cluster1 也好...
location /1 {
       proxy_pass http://cluster1;
       }
location /server_check { 
       check_status;
        }

配置效果图
在这里插入图片描述

检查 Nginx 语法

nginx -t

启动 Nginx

cd /usr/local/nginx/sbin
./nginx

地址访问查看效果(Nginx 没有单独配置端口直接访问 ip/server_check,配置了端口的访问 ip:端口/server_check )
在这里插入图片描述

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值