当前版本为1.12.2,命令:wget http://nginx.org/download/nginx-1.12.2.tar.gz

命令:wget https://github.com/chobits/ngx_http_proxy_connect_module/archive/master.zip

解压命令:

tar -xzvf nginx-1.12.2.tar.gz

unzip master.zip

进入nginx文件夹并安装connect补丁

cd nginx-1.12.2

patch -p1 < /root/nginx/ngx_http_proxy_connect_module/patch/proxy_connect.patch

后面是ngx_http_proxy_connect_module模块具体的路径

补丁版本对应关系请参考作者主页: https://github.com/chobits/ngx_http_proxy_connect_module

根据第一步查到已有的模块,加上本次需新增的模块

执行的命令: ./configure --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --add-module=/root/nginx/ngx_http_proxy_connect_module-master

编译时如出问题则需要添加依赖,百度一下即可。

一般还需要这些命令:

yum -y install libxml2 libxml2-dev libxslt-devel

yum -y install gd-devel

yum -y install perl-devel perl-ExtUtils-Embed

yum -y install GeoIP GeoIP-devel GeoIP-data

编译完成后执行 make

注意:千万别执行make install

编译成功移动新的nginx前先备份一个原来的nginx 出错了还可以还原回去

命令: mv /usr/sbin/nginx /usr/sbin/nginx.bak

然后把obj里的nginx移动到/usr/sbin/

配置nginx.conf文件

server {

listen 8443;

# dns resolver used by forward proxying

resolver 8.8.8.8;

# forward proxy for CONNECT request

proxy_connect;

proxy_connect_allow 443 563;

proxy_connect_connect_timeout 10s;

proxy_connect_read_timeout 10s;

proxy_connect_send_timeout 10s;

# forward proxy for non-CONNECT request

location / {

proxy_pass http://$host;

proxy_set_header Host $host;

}

}

重启nginx即可,测试结果