nginx 添加http_v2_module 模块,添加nginx_upstream_check_module 模块实现健康状态检测

1 查看版本和参数

/usr/local/webserver/nginx/sbin/nginx -V

configure arguments: --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.35

2 下载对应版本的tar.gz包到/usr/local/src/解压

http://nginx.org/download/nginx-1.16.1.tar.gz

3 添加模块,通过--with-http_v2_module启用ngx_http_v2_module模块

cd /usr/local/src/nginx-1.16.1

./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module  --with-pcre=/usr/local/src/pcre-8.35  --with-http_v2_module 

4 make,注意不要make install,否则直接覆盖了

5 备份,覆盖新的nginx。

#meke好了之后会在源码目录下objs 目录下产生nginx的二进制,然后把原先的nginx二进制命令备份,用上面编译好的nginx替换,最后reload的nignx就可以

cp /usr/local/webserver/nginx/sbin/nginx{ ,.bak}
cp -fr /usr/local/src/nginx-1.16.1/objs/nginx  /usr/local/webserver/nginx/sbin/nginx  
/usr/local/webserver/nginx/sbin/nginx -s reload 

6 重新查看/usr/local/webserver/nginx/sbin/nginx -V

configure arguments: --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-pcre=/usr/local/src/pcre-8.35

 

添加nginx_upstream_check_module 模块实现健康状态检测

参考 https://github.com/yaoweibin/nginx_upstream_check_module

# 操作目录 /opt/nginx
cd /opt/nginx
 
# 安装git
yum install -y git
 
# 拉取源码
git clone https://github.com/yaoweibin/nginx_upstream_check_module.git
 
# 安装打补丁软件
yum -y install patch
# nginx解压目录 /opt/nginx/nginx-1.18.0
cd /opt/nginx/nginx-1.18.0
 
# 给nginx打补丁(根据nginx版本号选择补丁包),打补丁这步操作不可少,否则会出出"[error] 29841#0: *23 http upstream check module can not find any check server, make sure you've added the check servers," 错误
patch -p1 < /opt/nginx/nginx_upstream_check_module/check_1.16.1+.patch
 
./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-stream --add-module=/opt/nginx/nginx_upstream_check_module
 
# 编译
make
 
# 进入objs,编译好的nginx在这个目录里
cd /opt/nginx/nginx-1.18.0/objs
 
# 备份旧的nginx
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
 
# 替换nginx
cp nginx /usr/local/nginx/sbin/nginx
 
systemctl restart nginx

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Nginx添加http_auth_request_module模块,你可以按照以下步骤操作: 1. 确认你的Nginx版本是否支持http_auth_request_module模块。你可以使用以下命令来检查: ``` nginx -V ``` 在输出结果中查找是否包含 "--with-http_auth_request_module" 字样,如果有,说明该模块已经被支持。 2. 如果你的Nginx版本不支持该模块,你需要重新编译Nginx并启用该模块。首先,下载Nginx的源代码: ``` wget http://nginx.org/download/nginx-x.x.x.tar.gz ``` (将 "x.x.x" 替换为你想要下载的版本号) 3. 解压源代码包: ``` tar -zxvf nginx-x.x.x.tar.gz ``` 4. 进入解压后的目录: ``` cd nginx-x.x.x ``` 5. 执行以下命令进行配置,确保启用了http_auth_request_module模块: ``` ./configure --with-http_auth_request_module ``` 6. 执行以下命令编译并安装Nginx: ``` make sudo make install ``` 7. 配置Nginx的配置文件(通常是位于 /etc/nginx/nginx.conf)。在合适的位置添加以下配置项: ``` location / { auth_request /auth; ... } location = /auth { internal; proxy_pass http://auth_backend; ... } ``` 这里的 "/auth" 是用来处理认证请求的URL,你可以根据需要进行修改。"http://auth_backend" 是实际处理认证请求的后端服务地址,也需要根据实际情况进行修改。 8. 保存并关闭配置文件后,重启Nginx服务: ``` sudo service nginx restart ``` 现在,你已经成功地添加http_auth_request_module模块Nginx中。你可以根据实际需求进一步配置和使用该模块来进行认证授权操作。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值