此文仅适用于nginx正向代理(https)升级参考,nginx 安装请查看官网教程,建议采用docker镜像安装,便于后面软件升级工作。
一、nginx当前信息:
版本:1.18.0
作用:搭建正向代理服务,需支持https的代理
第三方模块:ngx_http_proxy_connect_module
二、nginx 最新版本信息可通过http://nginx.org/en/download.html 可查询下载
三、ngx_http_proxy_connect_module模块可通过https://github.com/chobits/ngx_http_proxy_connect_module地址查看相关的信息及使用方法,注意与nginx版本的对应关系
四、升级操作
1、下载nginx:http://nginx.org/download/nginx-1.22.0.tar.gz,并上传到服务器指定目录
执行tar -zxvf nginx-1.22.0.tar.gz
2、下载ngx_http_proxy_connect_module:https://github.com/chobits/ngx_http_proxy_connect_module/archive/refs/heads/master.zip
注意:要按上图点击“Download ZIP”下载,上传到服务器指定目录,执行unzip ngx_http_proxy_connect_module_master.zip
3、这两个文件解压在同一目录下,cd 解压后的nginx根目录,
a、执行 patch -p1 < ../ ngx_http_proxy_connect_module_master/path/proxy_connect_rewrite_102101.patch
b、执行 nginx -V
复制configure arguments对应的参数信息,执行 ./configure --prefix=/app/nginx-1.22.0 --with-http_ssl_module --with-http_stub_status_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-pcre=../pcre-8.43 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.1j --add-module=../ngx_http_proxy_connect_module-master
标红的按实际目录修改
c、执行 make &make install 后,到安装目录将旧的nginx.conf文件复制过来,重新启动即可,如/app/nginx-1.22.0/sbin/nginx -c /app/nginx-1.22.0/conf/nginx.conf
d、ps -ef|grep nginx 即可查看进程是否启动
五、遇到的问题
1、下载ngx_http_proxy_connect_module模块必须通过上面我所说的形式下载,不然在make的时候会有 “\r ”类似异常
2、注意nginx 与ngx_http_proxy_connect_module 之间版本的对应关系,不能搞错,我用nginx 1.20.2 对应 ngx_http_proxy_connect_module 的proxy_connect_rewrite_102101.patch 在make 的时候会提示“proxy_connect undeclared(first use in this function )”错误
版权声明:内容来源于互联网和用户投稿 如有侵权请联系删除