1.部署准备工作
安装以及准备相关依赖包
[root@Aliyun ~]# yum -y install pcre-devel openssl openssl-devel patch
[root@Aliyun ~]# yum -y install lua-devel git
[root@Aliyun ~]# wget -c https://openresty.org/download/openresty-1.15.8.1.tar.gz
[root@Aliyun ~]# git clone https://github.com/chobits/ngx_http_proxy_connect_module.git
2.安装
[root@Aliyun ~]# tar -zxvf openresty-1.15.8.1.tar.gz
[root@Aliyun ~]# vim /root/openresty-1.15.8.1/bundle/nginx-1.15.8/auto/cc/gcc
# 将下列代码注释
# debug
CFLAGS="$CFLAGS -g"
[root@Aliyun ~]# mv openresty-1.15.8.1 /usr/local/src/
[root@Aliyun ~]# cd openresty-1.15.8.1
[root@Aliyun openresty-1.15.8.1]# ./configure --prefix=/opt/openresty --with-http_stub_status_module --with-http_sub_module \
--with-http_auth_request_module --with-http_addition_module \
--add-module=/usr/local/src/ngx_http_proxy_connect_module
[root@Aliyun openresty-1.15.8.1]# patch -d build/nginx-1.15.8/ -p 1 < /usr/local/src/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_101504.patch
[root@Aliyun ~]# gmake -j 8 && gmake install
[root@Aliyun ~]# echo "/opt/openresty/nginx/sbin/nginx" >> /etc/rc.d/rc.local
[root@Aliyun ~]# ln -s /opt/openresty/nginx/sbin/nginx /usr/sbin/nginx
[root@Aliyun ~]# nginx #启动服务
3.修改nginx.conf
[root@Aliyun ~]# vim /opt/openresty/nginx/conf/nginx.conf
在server模块中添加如下:
server {
listen 80;
resolver 8.8.8.8;
resolver_timeout 5s;
proxy_connect;
proxy_connect_allow 443 563;
proxy_connect_connect_timeout 10s;
proxy_connect_read_timeout 10s;
proxy_connect_send_timeout 10s;
location / {
proxy_pass $scheme://$host$request_uri;
proxy_set_header Host $http_host;
proxy_buffers 256 4k;
proxy_max_temp_file_size 0;
proxy_connect_timeout 30;
}
}
[root@Aliyun ~]# nginx -t #检查配置文件是否正确
[root@Aliyun ~]# nginx -s reload