正向代理

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值