{"id":84799,"date":"2026-07-26T17:57:06","date_gmt":"2026-07-26T09:57:06","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/84799.html"},"modified":"2026-07-26T17:57:06","modified_gmt":"2026-07-26T09:57:06","slug":"nginx%e5%9b%9b%e5%b1%82%e4%bb%a3%e7%90%86%e9%80%9a%e8%bf%87sni%e5%ae%9e%e7%8e%b0%e4%b8%8d%e5%90%8c%e7%9a%84%e5%9f%9f%e5%90%8d%e8%af%b7%e6%b1%82%e5%88%b0%e4%b8%8d%e5%90%8c%e7%9a%84%e4%b8%8a%e6%b8%b8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/84799.html","title":{"rendered":"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528"},"content":{"rendered":"<h3>Nginx\u4e4b\u56db\u5c42\u8d1f\u8f7d\u6a21\u5757ngx_stream_ssl_preread_module<\/h3>\n<p>ngx_stream_ssl_preread_module\u6a21\u5757\u662fNginx\u7684\u4e00\u4e2astream\u6a21\u5757&#xff0c;\u7528\u4e8e\u5728\u4e0d\u7ec8\u6b62SSL\/TLS\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\u4eceClientHello\u6d88\u606f\u4e2d\u63d0\u53d6\u4fe1\u606f&#xff0c;\u6bd4\u5982SNI&#xff08;\u670d\u52a1\u5668\u540d\u79f0\u6307\u793a&#xff09;\u3001ALPN&#xff08;\u5e94\u7528\u5c42\u534f\u8bae\u534f\u5546&#xff09;\u548c\u652f\u6301\u7684\u6700\u9ad8\u534f\u8bae\u7248\u672c\u3002<\/p>\n<p>\u8fd9\u4e2a\u6a21\u5757\u9ed8\u8ba4\u4e0d\u6784\u5efa&#xff0c;\u9700\u8981\u901a\u8fc7\u2013with-stream_ssl_preread_module\u914d\u7f6e\u53c2\u6570\u542f\u7528\u3002\u4e3b\u8981\u6307\u4ee4\u662fssl_preread&#xff0c;\u53d8\u91cf\u5305\u62ecssl_preread_server_name\u3001ssl_preread_alpn_protocols\u3001$ssl_preread_protocol\u7b49\u3002<\/p>\n<h4>\u6a21\u5757\u7f16\u8bd1\u4e0e\u542f\u7528<\/h4>\n<p>\u8be5\u6a21\u5757\u9ed8\u8ba4\u4e0d\u6784\u5efa&#xff0c;\u9700\u8981\u5728\u7f16\u8bd1 Nginx \u65f6\u663e\u5f0f\u542f\u7528&#xff1a;<\/p>\n<p>.\/configure &#8211;with-stream &#8211;with-stream_ssl_preread_module<br \/>\n<span class=\"token comment\"># \u5176\u4ed6\u539f\u6709\u53c2\u6570<\/span><br \/>\n<span class=\"token function\">make<\/span> <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">make<\/span> <span class=\"token function\">install<\/span><\/p>\n<p>\u7f16\u8bd1\u540e\u53ef\u901a\u8fc7 nginx -V 2&gt;&amp;1 | grep stream_ssl_preread\u9a8c\u8bc1\u6a21\u5757\u662f\u5426\u5df2\u5305\u542b<\/p>\n<p>[root&#064;nginx01 ~]# \/usr\/local\/nginx\/sbin\/nginx -V 2&gt;&amp;1 | grep stream_ssl_preread<br \/>\nconfigure arguments: &#8211;prefix&#061;\/usr\/local\/nginx &#8211;group&#061;nginx &#8211;user&#061;nginx &#8211;sbin-path&#061;\/usr\/local\/nginx\/sbin\/nginx &#8211;conf-path&#061;\/etc\/nginx\/nginx.conf &#8211;error-log-path&#061;\/var\/log\/nginx\/error.log &#8211;http-log-path&#061;\/var\/log\/nginx\/access.log &#8211;http-client-body-temp-path&#061;\/tmp\/nginx\/client_body &#8211;http-proxy-temp-path&#061;\/tmp\/nginx\/proxy &#8211;http-fastcgi-temp-path&#061;\/tmp\/nginx\/fastcgi &#8211;pid-path&#061;\/var\/run\/nginx.pid &#8211;lock-path&#061;\/var\/lock\/nginx &#8211;with-compat &#8211;with-file-aio &#8211;with-threads &#8211;with-http_addition_module &#8211;with-http_auth_request_module &#8211;with-http_dav_module &#8211;with-http_flv_module &#8211;with-http_gunzip_module &#8211;with-http_gzip_static_module &#8211;with-http_mp4_module &#8211;with-http_random_index_module &#8211;with-http_realip_module &#8211;with-http_secure_link_module &#8211;with-http_slice_module &#8211;with-http_ssl_module &#8211;with-http_stub_status_module &#8211;with-http_sub_module &#8211;with-http_v2_module &#8211;with-mail &#8211;with-mail_ssl_module &#8211;with-stream &#8211;with-stream_realip_module &#8211;with-stream_ssl_module &#8211;with-stream_ssl_preread_module &#8211;with-cc-opt&#061;&#039;-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE&#061;2 -fexceptions -fstack-protector-strong &#8211;param&#061;ssp-buffer-size&#061;4 -grecord-gcc-switches -m64 -mtune&#061;generic -fPIC&#039; &#8211;with-ld-opt&#061;&#039;-Wl,-z,relro -Wl,-z,now -pie&#039;<\/p>\n<h4>\u6838\u5fc3\u6307\u4ee4\u4e0e\u53d8\u91cf<\/h4>\n<p>\u6307\u4ee4&#xff1a;<\/p>\n<ul>\n<li>\n<p>ssl_preread on | off;<\/p>\n<p>\u5728 stream { server { &#8230; } }\u4e0a\u4e0b\u6587\u4e2d\u4f7f\u7528&#xff0c;\u5f00\u542f\u540e Nginx \u4f1a\u5728\u6536\u5230 ClientHello \u540e\u63d0\u53d6 SNI\u3001ALPN \u7b49\u4fe1\u606f\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u5185\u7f6e\u53d8\u91cf&#xff1a;<\/p>\n<table>\n<tr>\u53d8\u91cf\u540d\u542b\u4e49\u5f15\u5165\u7248\u672c<\/tr>\n<tbody>\n<tr>\n<td>$ssl_preread_server_name<\/td>\n<td>\u4ece SNI \u6269\u5c55\u4e2d\u63d0\u53d6\u7684\u670d\u52a1\u5668\u57df\u540d&#xff08;\u7a7a\u4e32\u8868\u793a\u672a\u63d0\u4f9b&#xff09;<\/td>\n<td>1.11.5<\/td>\n<\/tr>\n<tr>\n<td>$ssl_preread_alpn_protocols<\/td>\n<td>\u5ba2\u6237\u7aef\u5728 ALPN \u6269\u5c55\u4e2d\u58f0\u660e\u7684\u3001\u9017\u53f7\u5206\u9694\u7684\u534f\u8bae\u5217\u8868&#xff08;\u5982 h2,http\/1.1&#xff09;<\/td>\n<td>1.13.10<\/td>\n<\/tr>\n<tr>\n<td>$ssl_preread_protocol<\/td>\n<td>\u5ba2\u6237\u7aef\u652f\u6301\u7684\u6700\u9ad8 TLS\/SSL \u7248\u672c&#xff08;\u5982 TLSv1.3&#xff1b;\u7a7a\u4e32\u8868\u793a\u65e0 SSL \u63e1\u624b\u4fe1\u606f&#xff09;<\/td>\n<td>1.15.2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e3a\u7f16\u8bd1\u5b89\u88c5\u7684 Nginx \u914d\u7f6e\u56db\u5c42\u8d1f\u8f7d\u5747\u8861&#xff0c;\u53ef\u4ee5\u901a\u8fc7\u5b50\u914d\u7f6e\u6587\u4ef6\u7684\u65b9\u5f0f\u5b9e\u73b0\u6a21\u5757\u5316\u7ba1\u7406\u3002\u4ee5\u4e0b\u662f\u5b8c\u6574\u914d\u7f6e\u65b9\u6848&#xff1a;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7include\u6307\u4ee4\u5f15\u5165\u5b50\u914d\u7f6e\u6587\u4ef6\u3002\u521b\u5efa\u5b50\u914d\u7f6e\u6587\u4ef6&#xff0c;\u4f8b\u5982\u5728\/usr\/local\/nginx\/stream\/conf.d\/stream.conf&#xff0c;\u5e76\u5728\u8be5\u6587\u4ef6\u4e2d\u914d\u7f6e\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u3002\u5177\u4f53\u914d\u7f6e\u793a\u4f8b&#xff1a;\u4e3b\u914d\u7f6e\u6587\u4ef6&#xff08;nginx.conf&#xff09;\u4e2d&#xff0c;\u5728http\u914d\u7f6e\u5757\u4e4b\u5916&#xff0c;\u6dfb\u52a0stream\u914d\u7f6e\u5757\u7684\u5f15\u5165&#xff1a;\u6ce8\u610f&#xff1a;stream\u914d\u7f6e\u5757\u548chttp\u914d\u7f6e\u5757\u662f\u5e73\u7ea7\u7684<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir -p \/usr\/local\/nginx\/stream\/conf.d\/  #\u7528\u4e8e\u5b58\u653e\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u7684\u5b50\u914d\u7f6e\u6587\u4ef6\u76ee\u5f55<\/span><\/p>\n<p>\u7f16\u8f91\u4e3b\u914d\u7f6e\u6587\u4ef6 nginx.conf&#xff0c;\u5728 http\u5757\u540c\u7ea7\u6dfb\u52a0 stream\u914d\u7f6e&#xff1a;<\/p>\n<p>\u4ee3\u7406nginx-172.16.229.44<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim \/etc\/nginx\/nginx.conf<\/span><br \/>\nuser  nginx<span class=\"token punctuation\">;<\/span><br \/>\nworker_processes  auto<span class=\"token punctuation\">;<\/span><br \/>\nevents <span class=\"token punctuation\">{<\/span><br \/>\n    worker_connections  <span class=\"token number\">1024<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># HTTP \u5c42\u914d\u7f6e<\/span><br \/>\nhttp <span class=\"token punctuation\">{<\/span><br \/>\n    include       mime.types<span class=\"token punctuation\">;<\/span><br \/>\n    default_type  application\/octet-stream<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\"># &#8230; \u5176\u4ed6 http \u914d\u7f6e<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token comment\"># Stream \u5c42\u914d\u7f6e&#xff08;\u56db\u5c42\u8d1f\u8f7d\u5747\u8861&#xff09;<\/span><br \/>\nstream <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\"># \u5305\u542b\u6240\u6709\u542f\u7528\u7684\u5b50\u914d\u7f6e<\/span><br \/>\n    include \/usr\/local\/nginx\/stream\/conf.d\/*.conf<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u65e5\u5fd7\u683c\u5f0f<\/span><br \/>\n    log_format basic <span class=\"token string\">&#039;$remote_addr [$time_local] &#039;<\/span><br \/>\n                     <span class=\"token string\">&#039;$protocol $status $bytes_sent $bytes_received &#039;<\/span><br \/>\n                     <span class=\"token string\">&#039;$session_time &#034;$ssl_preread_server_name&#034;&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    access_log  logs\/stream_access.log  basic<span class=\"token punctuation\">;<\/span><br \/>\n    error_log   logs\/stream_error.log<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\">#\u6027\u80fd\u4f18\u5316\u5efa\u8bae<\/span><br \/>\n    <span class=\"token comment\"># \u542f\u7528\u7aef\u53e3\u590d\u7528&#xff08;Linux 3.9&#043;&#xff09;\u5982\u679c\u9700\u8981<\/span><br \/>\n    listen <span class=\"token number\">443<\/span> reuseport<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u8c03\u6574\u9884\u8bfb\u7f13\u51b2\u533a\u5927\u5c0f<\/span><br \/>\n    preread_buffer_size 32k<span class=\"token punctuation\">;<\/span><br \/>\n    preread_timeout 30s<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u8fde\u63a5\u4f18\u5316<\/span><br \/>\n    proxy_connect_timeout 5s<span class=\"token punctuation\">;<\/span><br \/>\n    proxy_timeout 60s<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">#\u521b\u5efa\u5b58\u653e\u56db\u5c42\u8d1f\u8f7d\u5747\u8861\u7684\u65e5\u5fd7\u76ee\u5f55<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># mkdir \/usr\/local\/nginx\/logs <\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># \/usr\/local\/nginx\/sbin\/nginx -t <\/span><br \/>\nnginx: the configuration <span class=\"token function\">file<\/span> \/etc\/nginx\/nginx.conf syntax is ok<br \/>\nnginx: configuration <span class=\"token function\">file<\/span> \/etc\/nginx\/nginx.conf <span class=\"token builtin class-name\">test<\/span> is successful<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># \/usr\/local\/nginx\/sbin\/nginx -s reload <\/span><\/p>\n<h4>\u914d\u7f6e\u793a\u4f8b<\/h4>\n<h5>1.\u57fa\u4e8e SNI \u7684\u5206\u6d41<\/h5>\n<p>\u5c06\u4e0d\u540c\u57df\u540d\u7684\u8bf7\u6c42\u8def\u7531\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668&#xff1a;<\/p>\n<p>\u57fa\u4e8e TLS SNI (Server Name Indication) \u7684\u56db\u5c42 TCP\/UDP \u4ee3\u7406\u914d\u7f6e&#xff0c;\u7528\u4e8e \u900f\u660e\u5730\u8f6c\u53d1 HTTPS \u6d41\u91cf&#xff0c;\u800c\u65e0\u9700\u89e3\u5bc6\u5176\u5185\u5bb9\u3002\u5b83\u5229\u7528\u4e86 Nginx \u7684 stream\u6a21\u5757&#xff08;\u5e38\u7528\u4e8e\u4ee3\u7406 TCP\/UDP \u6d41\u91cf&#xff09;\u548c ssl_preread\u6307\u4ee4\u3002<\/p>\n<p>\u8be5\u914d\u7f6e\u7684\u6838\u5fc3\u662f&#xff1a;\u6839\u636e\u5ba2\u6237\u7aef TLS \u63e1\u624b\u65f6\u53d1\u51fa\u7684 SNI \u4e3b\u673a\u540d&#xff0c;\u5c06\u52a0\u5bc6\u7684 HTTPS \u6d41\u91cf\u8f6c\u53d1\u5230\u4e0d\u540c\u7684\u540e\u7aef\u670d\u52a1\u5668\u3002<\/p>\n<h6>1.\u914d\u7f6e\u7ed3\u6784 (map\u5757)&#xff1a;<\/h6>\n<p>map $ssl_preread_server_name $backend {<br \/>\n    www.test1.com  backend1;<br \/>\n    www.test2.com     backend2;<br \/>\n    default        backend_default;<br \/>\n}<\/p>\n<ul>\n<li>\u76ee\u7684&#xff1a;\u5efa\u7acb\u4e00\u4e2a\u6620\u5c04\u8868\u3002<\/li>\n<li>\u53d8\u91cf&#xff1a;$ssl_preread_server_name\u662f ssl_preread\u6a21\u5757\u63d0\u53d6\u51fa\u7684 SNI \u4e3b\u673a\u540d\u3002<\/li>\n<li>\u903b\u8f91&#xff1a;\u68c0\u67e5 SNI \u503c\u3002\u5982\u679c\u662f www.test1.com&#xff0c;\u5219\u5c06\u53d8\u91cf $backend\u7684\u503c\u8bbe\u7f6e\u4e3a backend1&#xff1b;\u5982\u679c\u662f www.test2.com&#xff0c;\u5219\u8bbe\u7f6e\u4e3a backend2&#xff1b;\u5176\u4ed6\u6240\u6709\u60c5\u51b5&#xff08;\u5373 SNI \u4e0d\u5339\u914d\u6216\u4e3a\u7a7a&#xff09;&#xff0c;\u5219\u8bbe\u7f6e\u4e3a backend_default\u3002<\/li>\n<\/ul>\n<h6>2.\u4e0a\u6e38\u5b9a\u4e49 (upstream\u5757)&#xff1a;<\/h6>\n<p>upstream backend1 { server www.test1.com:443; }<br \/>\nupstream backend2 { server www.test2.com:443; }<br \/>\nupstream backend_default { server 10.0.0.3:443; }<\/p>\n<ul>\n<li>\u5b9a\u4e49\u4e86\u4e09\u4e2a\u4e0a\u6e38\u670d\u52a1\u5668\u7ec4\u3002\u5f53\u6d41\u91cf\u9700\u8981\u88ab\u8f6c\u53d1\u65f6&#xff0c;Nginx \u4f1a\u8fde\u63a5\u5230\u8fd9\u91cc\u5b9a\u4e49\u7684\u5730\u5740\u3002<\/li>\n<li>backend1\u548c backend2\u76f4\u63a5\u4ee3\u7406\u5230\u4e86\u4e92\u8054\u7f51\u4e0a\u7684\u771f\u5b9e\u670d\u52a1\u3002<\/li>\n<li>backend_default\u662f\u4e00\u4e2a\u9ed8\u8ba4\u7684\u6216\u5185\u90e8\u7684\u540e\u7aef&#xff0c;\u4f8b\u5982\u4e00\u4e2a\u9ed8\u8ba4\u7684\u7f51\u7ad9\u3001\u4e00\u4e2a\u9519\u8bef\u9875\u9762\u670d\u52a1\u5668&#xff0c;\u6216\u8005\u4e00\u4e2a\u7528\u4e8e\u5904\u7406\u7684\u4e2d\u95f4\u670d\u52a1&#xff08;\u5982 WAF&#xff09;\u3002<\/li>\n<\/ul>\n<h6>3.\u670d\u52a1\u5668\u5757 (server\u5757)&#xff1a;<\/h6>\n<p>server {<br \/>\n    listen 443;<br \/>\n    proxy_pass $backend;<br \/>\n    ssl_preread on;<br \/>\n}<\/p>\n<ul>\n<li>listen 443;&#xff1a;\u5728 TCP 443 \u7aef\u53e3\u4e0a\u76d1\u542c&#xff08;\u8fd9\u662f HTTPS \u7684\u6807\u51c6\u7aef\u53e3&#xff09;\u3002<\/li>\n<li>ssl_preread on;&#xff1a;\u5173\u952e\u6307\u4ee4\u3002\u5b83\u542f\u7528\u4e86\u4e00\u4e2a\u201c\u9884\u8bfb\u201d\u673a\u5236\u3002Nginx \u4f1a\u5728\u4e0d\u8fdb\u884c TLS \u89e3\u5bc6\u7684\u60c5\u51b5\u4e0b&#xff0c;\u4ece\u5ba2\u6237\u7aef\u53d1\u6765\u7684\u7b2c\u4e00\u4e2a\u6570\u636e\u5305&#xff08;Client Hello&#xff09;\u4e2d\u63d0\u53d6 SNI \u4fe1\u606f\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4e0d\u4f1a\u7834\u574f TLS \u7684\u52a0\u5bc6\u6027\u3002<\/li>\n<li>proxy_pass $backend;&#xff1a;\u5c06\u63a5\u6536\u5230\u7684\u6240\u6709\u6d41\u91cf\u8f6c\u53d1\u5230 $backend\u53d8\u91cf\u6240\u6307\u5411\u7684\u4e0a\u6e38\u670d\u52a1\u5668\u7ec4\u3002\u8fd9\u4e2a\u53d8\u91cf\u7684\u503c\u7531\u7b2c\u4e00\u6b65\u7684 map\u89c4\u5219\u6839\u636e SNI \u51b3\u5b9a\u3002<\/li>\n<\/ul>\n<h5>\u5de5\u4f5c\u539f\u7406\u4e0e\u6570\u636e\u6d41<\/h5>\n<li>\u5ba2\u6237\u7aef\u8fde\u63a5&#xff1a;\u4e00\u4e2a\u5ba2\u6237\u7aef&#xff08;\u5982\u6d4f\u89c8\u5668&#xff09;\u5c1d\u8bd5\u8fde\u63a5\u5230 www.test1.com\u7684 443 \u7aef\u53e3\u3002<\/li>\n<li>\u53d1\u9001 Client Hello&#xff1a;\u5ba2\u6237\u7aef\u53d1\u8d77 TLS \u63e1\u624b&#xff0c;\u5728 Client Hello\u6d88\u606f\u4e2d\u643a\u5e26 SNI \u5b57\u6bb5&#xff0c;\u660e\u6587\u6307\u51fa\u5b83\u60f3\u8981\u8fde\u63a5\u7684\u4e3b\u673a\u540d\u662f www.test1.com\u3002<\/li>\n<li>Nginx \u9884\u8bfb SNI&#xff1a;Nginx \u5728 stream\u5c42&#xff08;\u56db\u5c42&#xff09;\u63a5\u6536\u5230\u8fd9\u4e2a TCP \u6570\u636e\u5305\u3002ssl_preread on;\u6307\u4ee4\u4f7f\u5176\u80fd\u591f\u89e3\u6790 Client Hello\u5e76\u63d0\u53d6\u51fa www.test1.com\u3002<\/li>\n<li>\u6620\u5c04\u51b3\u7b56&#xff1a;\u63d0\u53d6\u51fa\u7684 SNI (www.test1.com) \u88ab\u8d4b\u503c\u7ed9\u53d8\u91cf $ssl_preread_server_name\u3002map\u89c4\u5219\u6839\u636e\u8fd9\u4e2a\u503c\u8fdb\u884c\u5339\u914d&#xff0c;\u51b3\u5b9a $backend\u7684\u503c\u4e3a backend1\u3002<\/li>\n<li>\u900f\u660e\u8f6c\u53d1&#xff1a;proxy_pass $backend;\u5c06\u6574\u4e2a TCP \u6d41&#xff08;\u5305\u542b\u540e\u7eed\u52a0\u5bc6\u7684 TLS \u5e94\u7528\u6570\u636e&#xff09;\u8f6c\u53d1\u7ed9 upstream backend1\u4e2d\u5b9a\u4e49\u7684\u670d\u52a1\u5668 www.test1.com:443\u3002<\/li>\n<li>\u5b8c\u6210\u8fde\u63a5&#xff1a;\u5ba2\u6237\u7aef\u4e0e\u771f\u6b63\u7684 www.test1.com\u670d\u52a1\u5668\u5b8c\u6210\u540e\u7eed\u7684 TLS \u63e1\u624b\u548c\u52a0\u5bc6\u901a\u4fe1&#xff0c;\u800c Nginx \u5728\u6574\u4e2a\u8fc7\u7a0b\u4e2d\u53ea\u662f\u4f5c\u4e3a\u900f\u660e\u7684\u201c\u7ba1\u9053\u201d&#xff0c;\u65e0\u6cd5\u770b\u5230\u89e3\u5bc6\u540e\u7684 HTTP \u5185\u5bb9\u3002<\/li>\n<h5>\u914d\u7f6e\u7528\u9014\u4e0e\u573a\u666f<\/h5>\n<ul>\n<li>SSL \u5378\u8f7d\u7f51\u5173\/\u53cd\u5411\u4ee3\u7406&#xff1a;\u53ef\u4ee5\u4f5c\u4e3a\u591a\u4e2a\u540e\u7aef HTTPS \u670d\u52a1\u7684\u7edf\u4e00\u5165\u53e3&#xff0c;\u6839\u636e\u57df\u540d\u5c06\u8bf7\u6c42\u5206\u53d1\u5230\u4e0d\u540c\u7684\u670d\u52a1\u5668&#xff0c;\u800c\u65e0\u9700\u5728\u6bcf\u4e2a\u540e\u7aef\u670d\u52a1\u5668\u4e0a\u914d\u7f6e SSL \u8bc1\u4e66\u3002<\/li>\n<li>\u96a7\u9053\u6216\u900f\u660e\u4ee3\u7406&#xff1a;\u5e38\u7528\u4e8e\u9700\u8981\u6839\u636e\u57df\u540d\u8def\u7531\u52a0\u5bc6\u6d41\u91cf\u7684\u573a\u666f&#xff0c;\u5982\u5728\u4f01\u4e1a\u5185\u90e8\u7f51\u7edc\u4e2d&#xff0c;\u5c06\u7279\u5b9a\u57df\u540d\u7684\u6d41\u91cf\u5f15\u5bfc\u81f3\u5b89\u5168\u5ba1\u67e5\u8bbe\u5907\u6216\u4ee3\u7406\u670d\u52a1\u5668\u3002<\/li>\n<li>\u8d1f\u8f7d\u5747\u8861\u7684\u524d\u7f6e\u8def\u7531&#xff1a;\u53ef\u4ee5\u5148\u6839\u636e SNI \u8fdb\u884c\u7c97\u7565\u8def\u7531&#xff0c;\u518d\u5728\u6bcf\u4e2a upstream\u5757\u5185\u5b9a\u4e49\u591a\u4e2a server\u5b9e\u73b0\u66f4\u7ec6\u7c92\u5ea6\u7684\u8d1f\u8f7d\u5747\u8861\u3002<\/li>\n<\/ul>\n<h5>\u91cd\u8981\u7279\u6027<\/h5>\n<ul>\n<li>\u5de5\u4f5c\u5728\u56db\u5c42 (Transport Layer)&#xff1a;\u8fd9\u662f\u5728 TCP \u5c42\u9762\u8fdb\u884c\u7684\u4ee3\u7406&#xff0c;\u4e0d\u6d89\u53ca\u4e03\u5c42&#xff08;HTTP&#xff09;\u534f\u8bae\u3002<\/li>\n<li>\u4e0d\u89e3\u5bc6 TLS&#xff1a;ssl_preread\u53ea\u8bfb\u53d6\u63e1\u624b\u521d\u671f\u7684\u660e\u6587\u90e8\u5206&#xff0c;\u5168\u7a0b\u4e0d\u89e3\u5bc6\u5e94\u7528\u5c42\u6570\u636e&#xff0c;\u56e0\u6b64\u65e0\u9700\u914d\u7f6e SSL \u8bc1\u4e66\u548c\u79c1\u94a5\u3002<\/li>\n<\/ul>\n<h5>\u5b8c\u6574\u914d\u7f6e<\/h5>\n<p><span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd \/usr\/local\/nginx\/stream\/conf.d\/<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;nginx01 conf.d<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim server_proxy.conf<\/span><br \/>\n<span class=\"token comment\">#SNI \u5230\u540e\u7aef\u6620\u5c04<\/span><br \/>\nmap <span class=\"token variable\">$ssl_preread_server_name<\/span> <span class=\"token variable\">$backend<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        www.test1.com  backend1<span class=\"token punctuation\">;<\/span><br \/>\n        www.test1.com     backend2<span class=\"token punctuation\">;<\/span><br \/>\n        default        backend_default<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    upstream backend1 <span class=\"token punctuation\">{<\/span> server www.test1.com:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    upstream backend2 <span class=\"token punctuation\">{<\/span> server www.test2.com:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    upstream backend_default <span class=\"token punctuation\">{<\/span> server <span class=\"token number\">10.0<\/span>.0.3:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>server <span class=\"token punctuation\">{<\/span><br \/>\n        listen <span class=\"token number\">443<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        proxy_pass <span class=\"token variable\">$backend<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        ssl_preread on<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># \/usr\/local\/nginx\/sbin\/nginx -s reload<\/span><\/p>\n<p>\u5ba2\u6237\u7aef\u9a8c\u8bc1<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl -v &#8211;resolve www.test1.com:443:172.16.229.44 https:\/\/www.baidu.com<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl -v &#8211;resolve www.test2.com:443:172.16.229.44 https:\/\/www.jd.com\/<\/span><\/p>\n<p>2. \u57fa\u4e8e ALPN \u534f\u8bae\u7684\u5206\u6d41<\/p>\n<p>\u6839\u636e\u5ba2\u6237\u7aef\u58f0\u660e\u7684\u5e94\u7528\u5c42\u534f\u8bae&#xff08;\u5982 HTTP\/2\u3001HTTP\/1.1&#xff09;\u8fdb\u884c\u8def\u7531&#xff1a;<\/p>\n<p>stream {<br \/>\n    map $ssl_preread_alpn_protocols $proxy {<br \/>\n        ~\\\\bh2\\\\b          127.0.0.1:8001;  # HTTP\/2<br \/>\n        ~\\\\bhttp\/1.1\\\\b    127.0.0.1:8002;  # HTTP\/1.1<br \/>\n        ~\\\\bxmpp-client\\\\b 127.0.0.1:8003;  # XMPP<br \/>\n    }<\/p>\n<p>    server {<br \/>\n        listen 9000;<br \/>\n        proxy_pass $proxy;<br \/>\n        ssl_preread on;<br \/>\n    }<br \/>\n}<\/p>\n<p>3. \u5355\u7aef\u53e3\u540c\u65f6\u652f\u6301 HTTP \u4e0e HTTPS<\/p>\n<p>\u901a\u8fc7\u68c0\u6d4b\u662f\u5426\u5305\u542b SSL \u63e1\u624b\u4fe1\u606f&#xff0c;\u5c06\u6d41\u91cf\u5206\u522b\u5bfc\u5411 HTTP \u6216 HTTPS \u540e\u7aef&#xff1a;<\/p>\n<p>map\u5757&#xff1a;<br \/>\nmap <span class=\"token variable\">$ssl_preread_protocol<\/span> <span class=\"token variable\">$back<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n     <span class=\"token string\">&#034;&#034;<\/span> http_backend<span class=\"token punctuation\">;<\/span><br \/>\n     default  https_backend<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n\u8fd9\u91cc\u5b9a\u4e49\u4e86\u4e00\u4e2a\u6620\u5c04&#xff0c;\u6839\u636e\u53d8\u91cf<span class=\"token variable\">$ssl_preread_protocol<\/span>\u7684\u503c\u6765\u51b3\u5b9a<span class=\"token variable\">$back<\/span>\u53d8\u91cf\u7684\u503c\u3002<br \/>\n<span class=\"token variable\">$ssl_preread_protocol<\/span>\u662fssl_preread\u6a21\u5757\u63d0\u4f9b\u7684\u53d8\u91cf&#xff0c;\u7528\u4e8e\u83b7\u53d6\u5ba2\u6237\u7aefTLS\u63e1\u624b\u4e2dClientHello\u6d88\u606f\u7684\u534f\u8bae\u7248\u672c&#xff08;\u5982TLSv1.2\u3001TLSv1.3\u7b49&#xff09;\u3002<br \/>\n\u5982\u679c<span class=\"token variable\">$ssl_preread_protocol<\/span>\u7684\u503c\u4e3a\u7a7a&#xff08;\u5373\u975eTLS\u6d41\u91cf&#xff09;&#xff0c;\u5219<span class=\"token variable\">$back<\/span>\u7684\u503c\u4e3ahttp_backend\u3002<br \/>\n\u5982\u679c<span class=\"token variable\">$ssl_preread_protocol<\/span>\u7684\u503c\u975e\u7a7a&#xff08;\u5373TLS\u6d41\u91cf&#xff09;&#xff0c;\u5219<span class=\"token variable\">$back<\/span>\u7684\u503c\u4e3ahttps_backend\u3002<\/p>\n<p>upstream\u5757&#xff1a;<br \/>\nupstream http_backend <span class=\"token punctuation\">{<\/span> server www.testpm.cn:80<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\nupstream https_backend <span class=\"token punctuation\">{<\/span> server www.test1.com:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n\u5b9a\u4e49\u4e86\u4e24\u4e2a\u4e0a\u6e38\u670d\u52a1\u5668\u7ec4\u3002<br \/>\nhttp_backend&#xff1a;\u6307\u5411\u4e00\u4e2aHTTP\u670d\u52a1\u5668&#xff08;www.testpm.cn\u768480\u7aef\u53e3&#xff09;\u3002<br \/>\nhttps_backend&#xff1a;\u6307\u5411\u4e00\u4e2aHTTPS\u670d\u52a1\u5668&#xff08;www.test1.com\u7684443\u7aef\u53e3&#xff09;\u3002<\/p>\n<p>server\u5757&#xff1a;<br \/>\nserver <span class=\"token punctuation\">{<\/span><br \/>\n     listen <span class=\"token number\">8081<\/span><span class=\"token punctuation\">;<\/span><br \/>\n     proxy_pass <span class=\"token variable\">$back<\/span><span class=\"token punctuation\">;<\/span><br \/>\n     ssl_preread on<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n\u76d1\u542c8081\u7aef\u53e3\u3002<br \/>\nssl_preread on<span class=\"token punctuation\">;<\/span>&#xff1a;\u542f\u7528ssl_preread\u529f\u80fd&#xff0c;\u5141\u8bb8Nginx\u5728\u8f6c\u53d1\u4e4b\u524d\u8bfb\u53d6TLS\u63e1\u624b\u7684\u521d\u59cb\u4fe1\u606f&#xff08;\u5982\u534f\u8bae\u7248\u672c\u3001SNI\u7b49&#xff09;&#xff0c;\u800c\u4e0d\u8fdb\u884c\u89e3\u5bc6\u3002<br \/>\nproxy_pass <span class=\"token variable\">$back<\/span><span class=\"token punctuation\">;<\/span>&#xff1a;\u5c06\u6d41\u91cf\u8f6c\u53d1\u5230\u7531<span class=\"token variable\">$back<\/span>\u53d8\u91cf\u6307\u5b9a\u7684\u4e0a\u6e38\u670d\u52a1\u5668\u7ec4\u3002<\/p>\n<p>\u5b8c\u6574\u914d\u7f6e<\/p>\n<p><span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># cd \/usr\/local\/nginx\/stream\/conf.d\/<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;nginx01 conf.d<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vim server_proxy.conf<\/span><br \/>\n map <span class=\"token variable\">$ssl_preread_protocol<\/span> <span class=\"token variable\">$back<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string\">&#034;&#034;<\/span>       http_backend<span class=\"token punctuation\">;<\/span><br \/>\n        default  https_backend<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    upstream http_backend <span class=\"token punctuation\">{<\/span> server www.testpm.cn:80<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    upstream https_backend <span class=\"token punctuation\">{<\/span> server www.test1.com:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>server <span class=\"token punctuation\">{<\/span><br \/>\n        listen <span class=\"token number\">8081<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        proxy_pass <span class=\"token variable\">$back<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        ssl_preread on<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;nginx01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># vi \/etc\/hosts<\/span><br \/>\n<span class=\"token number\">172.16<\/span>.229.47 www.testpm.cn   <span class=\"token comment\">#\u505a\u672c\u5730\u89e3\u6790\u57df\u540d\u5230\u6d4b\u8bd5\u865a\u62df\u673aip<\/span><\/p>\n<p>\u5ba2\u6237\u7aef\u9a8c\u8bc1<br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl -vl  http:\/\/172.16.229.44:8081<\/span><br \/>\n<span class=\"token punctuation\">[<\/span>root&#064;web01 ~<span class=\"token punctuation\">]<\/span><span class=\"token comment\"># curl -vlk  https:\/\/172.16.229.44:8081<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260726095705-6a65d9f1591c8.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u573a\u666f4&#xff1a;TCP\/UDP \u6df7\u5408\u534f\u8bae\u5206\u6d41<\/p>\n<p>stream <span class=\"token punctuation\">{<\/span><br \/>\n    map <span class=\"token variable\">$ssl_preread_protocol<\/span> <span class=\"token variable\">$upstream<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string\">&#034;&#034;<\/span>            tcp_backend<span class=\"token punctuation\">;<\/span>   <span class=\"token comment\"># \u975e SSL \u6d41\u91cf<\/span><br \/>\n        <span class=\"token string\">&#034;TLSv1.2&#034;<\/span>     tls_backend<span class=\"token punctuation\">;<\/span>   <span class=\"token comment\"># TLS 1.2 \u6d41\u91cf<\/span><br \/>\n        <span class=\"token string\">&#034;TLSv1.3&#034;<\/span>     tls_backend<span class=\"token punctuation\">;<\/span>   <span class=\"token comment\"># TLS 1.3 \u6d41\u91cf<\/span><br \/>\n        default       default_backend<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    upstream tcp_backend <span class=\"token punctuation\">{<\/span> server <span class=\"token number\">10.0<\/span>.1.1:22<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span>      <span class=\"token comment\"># SSH<\/span><br \/>\n    upstream tls_backend <span class=\"token punctuation\">{<\/span> server <span class=\"token number\">10.0<\/span>.1.2:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span>     <span class=\"token comment\"># HTTPS<\/span><br \/>\n    upstream default_backend <span class=\"token punctuation\">{<\/span> server <span class=\"token number\">10.0<\/span>.1.3:8080<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>    server <span class=\"token punctuation\">{<\/span><br \/>\n        listen <span class=\"token number\">8443<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        proxy_pass <span class=\"token variable\">$upstream<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        ssl_preread on<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<li>\u7070\u5ea6\u53d1\u5e03\/\u91d1\u4e1d\u96c0\u53d1\u5e03<\/li>\n<p>stream <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\"># \u6309\u57df\u540d\u6743\u91cd\u5206\u6d41<\/span><br \/>\n    split_clients <span class=\"token string\">&#034;<span class=\"token variable\">${ssl_preread_server_name}<\/span><span class=\"token variable\">${remote_addr}<\/span>&#034;<\/span> <span class=\"token variable\">$backend<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token number\">10<\/span>%     canary_backend<span class=\"token punctuation\">;<\/span><br \/>\n        *       production_backend<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    upstream canary_backend <span class=\"token punctuation\">{<\/span> server <span class=\"token number\">10.0<\/span>.2.1:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n    upstream production_backend <span class=\"token punctuation\">{<\/span> server <span class=\"token number\">10.0<\/span>.2.2:443<span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>    server <span class=\"token punctuation\">{<\/span><br \/>\n        listen <span class=\"token number\">443<\/span> reuseport<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">#\u652f\u6301\u7aef\u53e3\u590d\u7528&#xff0c;\u524d\u63d0\u662f\u5728stream\u5757\u4e2d\u5df2\u7ecf\u5f00\u542f<\/span><br \/>\n        proxy_pass <span class=\"token variable\">$backend<\/span><span class=\"token punctuation\">;<\/span><br \/>\n        ssl_preread on<span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h4>\u6ce8\u610f\u4e8b\u9879<\/h4>\n<ul>\n<li>\n<p>\u8be5\u6a21\u5757\u5de5\u4f5c\u5728 stream \u4e0a\u4e0b\u6587&#xff08;\u56db\u5c42\u4ee3\u7406&#xff09;&#xff0c;\u4e0e http \u6a21\u5757\u7684 SSL \u5904\u7406\u65e0\u5173\u3002<\/p>\n<\/li>\n<li>\n<p>\u542f\u7528 ssl_preread on\u540e&#xff0c;Nginx \u4e0d\u4f1a\u89e3\u5bc6 SSL \u6d41\u91cf&#xff0c;\u4ec5\u63d0\u53d6 ClientHello \u4e2d\u7684\u4fe1\u606f&#xff0c;\u56e0\u6b64\u65e0\u6cd5\u83b7\u53d6 HTTP \u5934\u90e8\u7b49\u5e94\u7528\u5c42\u6570\u636e\u3002<\/p>\n<\/li>\n<li>\n<p>\u82e5\u914d\u7f6e\u540e\u51fa\u73b0 unknown directive &#039;ssl_preread&#039;\u9519\u8bef&#xff0c;\u8bf4\u660e\u6a21\u5757\u672a\u6b63\u786e\u7f16\u8bd1&#xff0c;\u9700\u6309\u4e0a\u8ff0\u6b65\u9aa4\u91cd\u65b0\u7f16\u8bd1 Nginx\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u901a\u8fc7\u8be5\u6a21\u5757&#xff0c;\u53ef\u4ee5\u5728\u4fdd\u6301 SSL \u52a0\u5bc6\u5b8c\u6574\u6027\u7684\u524d\u63d0\u4e0b&#xff0c;\u5b9e\u73b0\u57fa\u4e8e\u57df\u540d\u3001\u534f\u8bae\u7248\u672c\u7b49\u4fe1\u606f\u7684\u7075\u6d3b\u8def\u7531&#xff0c;\u9002\u7528\u4e8e\u7f51\u5173\u3001\u8d1f\u8f7d\u5747\u8861\u7b49\u573a\u666f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nginx\u4e4b\u56db\u5c42\u8d1f\u8f7d\u6a21\u5757ngx_stream_ssl_preread_module<br \/>\nngx_stream_ssl_preread_module\u6a21\u5757\u662fNginx\u7684\u4e00\u4e2astream\u6a21\u5757&#xff0c;\u7528\u4e8e\u5728\u4e0d\u7ec8\u6b62SSL\/TLS\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\u4eceClientHello\u6d88\u606f\u4e2d\u63d0\u53d6\u4fe1\u606f&#xff0c;\u6bd4\u5982SNI&#xff08;\u670d\u52a1\u5668\u540d\u79f0\u6307\u793a&#xff09;\u3001ALPN&#xff08;\u5e94\u7528\u5c42\u534f\u8bae\u534f\u5546&#xff09;\u548c\u652f\u6301\u7684\u6700\u9ad8\u534f\u8bae\u7248\u672c\u3002<br \/>\n\u8fd9\u4e2a\u6a21\u5757\u9ed8\u8ba4\u4e0d\u6784\u5efa&#xff0c;\u9700\u8981\u901a\u8fc7\u2013with-s<\/p>\n","protected":false},"author":2,"featured_media":84798,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[117,606,43],"topic":[],"class_list":["post-84799","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-nginx","tag-ssl","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/84799.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Nginx\u4e4b\u56db\u5c42\u8d1f\u8f7d\u6a21\u5757ngx_stream_ssl_preread_module ngx_stream_ssl_preread_module\u6a21\u5757\u662fNginx\u7684\u4e00\u4e2astream\u6a21\u5757&#xff0c;\u7528\u4e8e\u5728\u4e0d\u7ec8\u6b62SSL\/TLS\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\u4eceClientHello\u6d88\u606f\u4e2d\u63d0\u53d6\u4fe1\u606f&#xff0c;\u6bd4\u5982SNI&#xff08;\u670d\u52a1\u5668\u540d\u79f0\u6307\u793a&#xff09;\u3001ALPN&#xff08;\u5e94\u7528\u5c42\u534f\u8bae\u534f\u5546&#xff09;\u548c\u652f\u6301\u7684\u6700\u9ad8\u534f\u8bae\u7248\u672c\u3002 \u8fd9\u4e2a\u6a21\u5757\u9ed8\u8ba4\u4e0d\u6784\u5efa&#xff0c;\u9700\u8981\u901a\u8fc7\u2013with-s\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/84799.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-26T09:57:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260726095705-6a65d9f1591c8.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84799.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/84799.html\",\"name\":\"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-26T09:57:06+00:00\",\"dateModified\":\"2026-07-26T09:57:06+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/84799.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/84799.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/84799.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/84799.html","og_locale":"zh_CN","og_type":"article","og_title":"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Nginx\u4e4b\u56db\u5c42\u8d1f\u8f7d\u6a21\u5757ngx_stream_ssl_preread_module ngx_stream_ssl_preread_module\u6a21\u5757\u662fNginx\u7684\u4e00\u4e2astream\u6a21\u5757&#xff0c;\u7528\u4e8e\u5728\u4e0d\u7ec8\u6b62SSL\/TLS\u8fde\u63a5\u7684\u60c5\u51b5\u4e0b\u4eceClientHello\u6d88\u606f\u4e2d\u63d0\u53d6\u4fe1\u606f&#xff0c;\u6bd4\u5982SNI&#xff08;\u670d\u52a1\u5668\u540d\u79f0\u6307\u793a&#xff09;\u3001ALPN&#xff08;\u5e94\u7528\u5c42\u534f\u8bae\u534f\u5546&#xff09;\u548c\u652f\u6301\u7684\u6700\u9ad8\u534f\u8bae\u7248\u672c\u3002 \u8fd9\u4e2a\u6a21\u5757\u9ed8\u8ba4\u4e0d\u6784\u5efa&#xff0c;\u9700\u8981\u901a\u8fc7\u2013with-s","og_url":"https:\/\/www.wsisp.com\/helps\/84799.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-26T09:57:06+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/07\/20260726095705-6a65d9f1591c8.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/84799.html","url":"https:\/\/www.wsisp.com\/helps\/84799.html","name":"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-26T09:57:06+00:00","dateModified":"2026-07-26T09:57:06+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/84799.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/84799.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/84799.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Nginx\u56db\u5c42\u4ee3\u7406\u901a\u8fc7SNI\u5b9e\u73b0\u4e0d\u540c\u7684\u57df\u540d\u8bf7\u6c42\u5230\u4e0d\u540c\u7684\u4e0a\u6e38\u670d\u52a1\u5668 nginx\u4e4bngx_stream_ssl_preread_module\u6a21\u5757\u4f7f\u7528"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84799","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=84799"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/84799\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/84798"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=84799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=84799"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=84799"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=84799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}