方案前文:創建一個家庭私有云盤方案系列教程+N2n+Nextcloudnginx
上一篇:家庭私有云盤系列教程-本地搭建家庭NAS方案c++
上文已經提到在公網上建立N2N中心節點及客戶端節點,這裏也再也不提起。bash
做爲後續內容,這將說明下在公網服務器使用Nginx轉發tcp流量到內網上。服務器
#安裝編譯支持庫 mkdir /mnt/tools -p cd /mnt/tools yum -y install gcc automake autoconf libtool make yum install gcc gcc-c++ #安裝PCRE wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz tar -xzf pcre-8.40.tar.gz -C ./ cd pcre-8.40 ./configure --prefix=/usr/local/pcre make && make install cd .. #安裝zlib wget http://zlib.net/zlib-1.2.11.tar.gz tar -xzf zlib-1.2.11.tar.gz -C ./ cd zlib-1.2.11 ./configure --prefix=/usr/local/zlib make && make install cd .. #安裝openss wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz tar -xzf openssl-1.0.2k.tar.gz -C ./ #注意,這裏不須要進行安裝,後面步驟省略。 #編譯安裝nginx wget http://nginx.org/download/nginx-1.12.0.tar.gz tar -xzf nginx-1.12.0.tar.gz -C ./ cd nginx-1.12.0 ./configure \ --prefix=/usr/local/nginx \ --sbin-path=/usr/local/nginx/nginx \ --conf-path=/usr/local/nginx/nginx.conf \ --pid-path=/usr/local/nginx/nginx.pid \ --with-http_ssl_module \ --with-pcre=/mnt/tools/pcre-8.40/ \ --with-zlib=/mnt/tools/zlib-1.2.11/ \ --with-openssl=/mnt/tools/openssl-1.0.2k/ \ --with-stream #注:cpre、zlib、openssl等依賴包的路徑是解壓的源碼路徑不是安裝後的路徑。 make make install
cd /usr/local/nginx/ vi nginx.conf
尾部追加配置session
stream { log_format proxy '$remote_addr [$time_local] ' '$protocol $status $bytes_sent $bytes_received ' '$session_time "$upstream_addr" ' '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"'; access_log /var/log/nginx/tcp-access.log proxy ; open_log_file_cache off; include /usr/local/nginx/conf.d/*.stream; }
建立日誌目錄、配置目錄tcp
mkdir /var/log/nginx/ mkdir /usr/local/nginx/conf.d/ cd /usr/local/nginx/conf.d/
vi /usr/local/nginx/conf.d/tcp-local-10.0.0.25.stream
upstream TCP10251 { hash $remote_addr consistent; server 10.0.0.25:22; } upstream TCP10252 { hash $remote_addr consistent; server 10.0.0.25:80; } upstream TCP10253 { hash $remote_addr consistent; server 10.0.0.25:3306; } upstream TCP10254 { hash $remote_addr consistent; server 10.0.0.25:10025; } server { listen 10251; proxy_connect_timeout 5s; proxy_timeout 300s; proxy_pass TCP10251; } server { listen 10252; proxy_connect_timeout 5s; proxy_timeout 300s; proxy_pass TCP10252; } server { listen 10253; proxy_connect_timeout 5s; proxy_timeout 300s; proxy_pass TCP10253; } server { listen 10254; proxy_connect_timeout 5s; proxy_timeout 300s; proxy_pass TCP10254; }
/usr/local/nginx/nginx
http://115.0.0.1:10254/測試
http://115.0.0.1:10254/Evil.Minds.2015.S01.EP01.1080P.WEB-DL.mp4spa
後一篇:家庭私有云盤系列教程-安裝使用NextCloud我的雲存儲系統.net
(完)代理