Nginx server settings http / https forward proxy, use ngx_http_proxy_connect_module module

First, the preparatory work
system environment: CentOS 7.6 64
New Installation requires simple set about,

$ ip addr 

The default network card is found not started.

vi /etc/sysconfig/network-scripts/ifcfg-ens33

After the ONBOOT = no change ONBOOT = yes, save the Network Service Restart

$ sudo service network restart

Second, start the installation
compilation tools

yum install gcc gcc-c++  make -y
yum install rpm-build rpmdevtools -y

Installation depends

yum install pcre-devel pcre -y
yum install zlib-devel zlib -y
yum install openssl-devel openssl -y
#yum install redhat-lsb-core -y

No git, install a well wget

yum install git
yum -y install wget

Download module, the use to

git clone https://github.com/chobits/ngx_http_proxy_connect_module.git

Download Nginx

$ wget http://nginx.org/download/nginx-1.9.2.tar.gz
$ tar -xzvf nginx-1.9.2.tar.gz

Into the extracted directory

$ cd nginx-1.9.2/

Setting parameters (translation module)

$ patch -p1 < /root/ngx_http_proxy_connect_module/patch/proxy_connect.patch
$ ./configure --add-module=/root/ngx_http_proxy_connect_module

Compile - Installation

$ make && make install

Start nginx

cd /usr/local/nginx/sbin/
./nginx 

Nginx.conf modify files, the core code
-> Configure two

#http协议 80端口 -只是监听端口
server {
        listen       80;
	resolver 114.114.114.114;
        #server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
	           proxy_pass $scheme://$http_host$request_uri;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 #https协议(SSL) 443端口 -只是监听端口
    server {
        resolver 114.114.114.114; #DNS
        listen 443;
        #server_name  localhost; #要做正向代理, 不需要server_name
        proxy_connect;
        proxy_connect_allow            443 563;
        proxy_connect_connect_timeout  10s;
        proxy_connect_read_timeout     10s;
        proxy_connect_send_timeout     10s;
     
        #access_log /var/log/nginx/http_proxy.access.log main;
        #error_log /var/log/nginx/http_proxy.error.log;
     
        location / {
            proxy_pass $scheme://$http_host$request_uri;
        }
    }

Reload Configuration

./nginx -s reload

Use Nginx forward proxy, next to Google expanded proxy agent network settings.
Article Address: https://blog.csdn.net/NL45426/article/details/101170394

oil
Published 11 original articles · won praise 0 · Views 5116

Guess you like

Origin blog.csdn.net/NL45426/article/details/101170071