赞
踩
节点 | IP | 描述 |
server | 192.168.0.3 | 可访问公网 |
client | 192.168.0.4 | 不可访问公网 |
- $ yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel patch pcre pcre-devel
- $ wget http://nginx.org/download/nginx-1.16.0.tar.gz
- $ git clone https://github.com/chobits/ngx_http_proxy_connect_module.git
- $ tar xf nginx-1.16.0.tar.gz -C /usr/local/src/
- $ cd /usr/local/src/nginx-1.16.0/
- $ patch -p1 < /root/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_101504.patch
- #此处proxy_connect_module选择与nginx版本有关
- $ ./configure --add-module=/root/ngx_http_proxy_connect_module/
- $ make -j 4
- #我这里是4核的cpu
- $ make install
- worker_processes 2;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- sendfile on;
- keepalive_timeout 65;
- resolver 114.114.114.114;
- server {
- listen 6666;
- proxy_connect;
- location / {
- proxy_pass $scheme://$host$request_uri;
- }
- }
- server {
- listen 8443;
-
- # dns resolver used by forward proxying
- resolver 114.114.114.114;
-
- # 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;
- }
- }
-
- server {
- resolver 8.8.8.8;
- listen 8080;
- location / {
- proxy_pass http://$http_host$request_uri;
- proxy_set_header HOST $http_host;
- proxy_buffers 256 4k;
- proxy_max_temp_file_size 0k;
- proxy_connect_timeout 30;
- proxy_send_timeout 60;
- proxy_read_timeout 60;
- proxy_next_upstream error timeout invalid_header http_502;
- }
- }
- }
- $ vim /etc/profile
- export http_proxy=http://192.168.0.3:8080/
- export https_proxy=https://192.168.0.3:8443/
- $ source /etc/profile
测试
- # http测试
- $ curl http://www.baidu.com
- # https 测试
- $ curl https://www.baidu.com
- $ vim /etc/wgetrc
- http_proxy=http://192.168.0.3:8080/
- https_proxy=https://192.168.0.3:8443/
- $ source /etc/wgetrc
分别使用wget http://xxxx和wget https://xxxx测试下载即可。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。