Nginx 閰嶇疆 stream SSL 绗洓灞?浠g悊

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx 閰嶇疆 stream SSL 绗洓灞?浠g悊相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/%e7%89%b9%e6%ae%8a' title='鐗规畩'>鐗规畩   span   杩炴帴   read   鍦板潃   gcc   enabled   閰嶇疆鏂囦欢   nbsp   

鍦烘櫙锛氭湇鍔″櫒F閽堝璁块棶缁堢闇€瑕佹坊鍔犵櫧鍚嶅崟鎿嶄綔锛岀敱鍒扮粓绔暟閲忚緝澶氾紝鎵€浠ョ敤浜嗕竴鍙颁唬鐞嗘湇鍔″櫒 P锛屽湪鏈嶅姟F涓坊鍔?鏈嶅姟鍣≒ IP鍦板潃鐨勭櫧鍚嶅崟锛屾墍鏈夌粓绔闂湇鍔″櫒P

鐢变簬鎴戝凡缁忓畨瑁呰繃 Nginx 鎵€浠ュ彧闇€瑕佹坊鍔犳ā鍧楃殑閰嶇疆锛岃繖閲屽厛璇存槑 stream 鍥涘眰浠g悊鐨勫疄鐜版柟寮忥紝锛堜粎婊¤冻椤圭洰闇€瑕侀厤缃紝鍏跺畠閰嶇疆椤瑰彲鐧惧害鍙傝€冪浉搴旂殑璇存槑锛?/p>

鍒囨崲鍒板畨瑁呯洰褰曚笅

[root@localhost nginx-1.12.2]# pwd
/usr/local/iron/nginx-1.12.2
[root@localhost nginx-1.12.2]# 
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module
[root@localhost nginx-1.12.2]# make
[root@localhost sbin]# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx-no-strem
[root@localhost sbin]# cp /usr/local/iron/nginx-1.12.2/objs/nginx /usr/local/nginx/sbin/nginx
cp锛氭槸鍚﹁鐩?span style="color: #800000;">"/usr/local/nginx/sbin/nginx"锛?y
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module
[root@localhost sbin]# 

 

nginx.config

worker_processes  1;

events 
    worker_connections 1024;


stream  
    map $ssl_preread_server_name $name 
        default                  backend;
    #   backend.example.com      backend2;
    


    upstream backend 
        server ironfo.com:443;
    #    server 192.168.0.4:12345;
    
 
    #upstream backend2 
    #    server 192.168.0.1:12345;
    #    server 192.168.0.2:12345;
    #

    server 
        listen      8080;
        proxy_pass  $name;
        ssl_preread on;
    
 

 

[root@localhost sbin]# /usr/local/nginx/sbin/nginx -s reload  閲嶆柊鍔犺浇閰嶇疆鏂囦欢

 

 鎶€鏈浘鐗? src=

 

 姝ゆ椂璁块棶缃戠珯浼氭彁绀轰笉瀹夊叏鐨勮繛鎺?/p>

閰嶇疆 hosts 鏂囦欢锛堢敱浜庨」鐩殑鐗规畩鎬э紝甯镐笉浼氳繖鏍风殑鎿嶄綔锛屾病蹇呰杩欎箞缁曚竴鍦堬級

192.168.1.1 涓篘ginx 鏈嶅姟鍣ㄧ殑IP

鎶€鏈浘鐗? src=

 

 閲嶆柊娴忚鍣紝鍙甯歌闂?/p>

 鎶€鏈浘鐗? src=

 

以上是关于Nginx 閰嶇疆 stream SSL 绗洓灞?浠g悊的主要内容,如果未能解决你的问题,请参考以下文章

SpringBoot+Druid+Mybatis閰嶇疆澶氭暟鎹簮

绗叓绔狅細绮変笣

闆跺熀纭€瀛ginx銆?銆憒 Nginx 甯哥敤鐨勫懡浠ゅ拰閰嶇疆鏂囦欢

Linux閰嶇疆闈欐€両P

Spring Cloud Alibaba锛堜簩锛?閰嶇疆涓績澶氶」鐩€佸閰嶇疆鏂囦欢銆佸垎鐩綍瀹炵幇

HBase闆嗙兢鎼缓閮ㄥ垎閰嶇疆