卸载nginx
rm -rf file /usr/local/nginx*
nginx正向代理默认只支持http,不支持https,需借助第三方模块“ngx_http_proxy_connect_module”来实现(https://github.com/chobits/ngx_http_proxy_connect_module)。
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
wget http://nginx.org/download/nginx-1.16.0.tar.gz tar -xzvf nginx-1.16.0.tar.gz cd nginx-1.16.0 patch -p1 < /root/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_101504.patch #这里需要根据nginx版本选择 ./configure --add-dynamic-module=/root/ngx_http_proxy_connect_module --with-http_ssl_module #ssl模块根据自己需求加 make && make install
修改nginx配置
load_module /usr/local/nginx/modules/ngx_http_proxy_connect_module.so; server { listen 7890; # 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 $scheme://$host; proxy_set_header Host $host; } location ^~ /bx_wx_api/{ proxy_pass https://api.weixin.qq.com/; proxy_set_header Host $host; #必带头部信息,不然会302重定向返回 } }
最后启动nginx 生效
/usr/local/nginx/sbin/nginx -s reload
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/198809.html