#!/bin/bash
    echo 'start install nginx...'
    cd 
   # wget http://nginx.org/download/nginx-1.9.12.tar.gz -O nginx-1.9.12.tar.gz
   # tar -xzvf nginx-1.9.12.tar.gz
    yum -y install gcc pcre-devel openssl-devel git  httpd-tools
    yum -y install gcc automake autoconf libtool make unzip
    yum -y install gcc-c++
    wget http://xianggege.13shop.net/ngx_http_proxy_connect_module.tar.gz
	wget http://xianggege.13shop.net/openssl-1.1.1c.tar.gz
	tar zxvf openssl-1.1.1c.tar.gz
    tar zxvf ngx_http_proxy_connect_module.tar.gz
    # cd nginx-1.9.12/
    # patch -p1 < /root/ngx_http_proxy_connect_module/patch/proxy_connect.patch
    #./configure --add-module=/root/ngx_http_proxy_connect_module
    wget https://openresty.org/download/openresty-1.19.3.1.tar.gz
    tar zxvf openresty-1.19.3.1.tar.gz

    cd  openresty-1.19.3.1/
    ./configure --add-module=/root/ngx_http_proxy_connect_module --with-openssl=/root/openssl-1.1.1c
    patch -d build/nginx-1.19.3/ -p 1 < /root/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_101504.patch

    make
    make install


##################################################################
 wget http://xianggege.13shop.net/nginx6.conf  -O   /usr/local/openresty/nginx/conf/nginx.conf
 wget http://xianggege.13shop.net/proxy_auth.lua  -O   /usr/local/openresty/nginx/conf/proxy_auth.lua



wget http://xianggege.13shop.net/http.conf  -O /usr/local/openresty/nginx/conf/http.conf
wget http://xianggege.13shop.net/nginx6  -O /etc/init.d/nginx




cat  << EOF  > /etc/sysctl.conf
net.netfilter.nf_conntrack_tcp_loose = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
EOF
sysctl   -p




########################################################

    chmod  +x /etc/init.d/nginx
    chkconfig nginx on
    /etc/init.d/nginx restart
    ln -s /usr/local/openresty/nginx/sbin/nginx  /sbin/
	echo "/usr/local/openresty/nginx/sbin/nginx" >> /etc/rc.local
    echo 'install nginx successful.'

    echo  "htpasswd -c /usr/local/openresty/nginx/conf/pwd username  add  user "