{"id":39141,"date":"2025-05-22T08:02:12","date_gmt":"2025-05-22T00:02:12","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/39141.html"},"modified":"2025-05-22T08:02:12","modified_gmt":"2025-05-22T00:02:12","slug":"scgi-%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/39141.html","title":{"rendered":"SCGI \u670d\u52a1\u5668\u8be6\u89e3"},"content":{"rendered":"<h3>1 \u534f\u8bae\u4e0e\u62a5\u6587\u683c\u5f0f<\/h3>\n<table>\n<tr>\u9879\u76ee\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u8fde\u63a5\u7c7b\u578b<\/td>\n<td>\u957f\u8fde\u63a5&#xff0c;\u5355\u6761 TCP\/UnixSocket \u53ef\u4f20\u591a\u8bf7\u6c42&#xff1b;\u7531\u524d\u7aef&#xff08;Nginx \u7b49&#xff09;\u7ef4\u62a4 keep-alive\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u62a5\u6587\u5206\u6bb5<\/td>\n<td>&#034;&lt;len&gt;:&#034; &#043; &lt;header netstring&gt; &#043; &#034;,&#034; &#043; &lt;body&gt;<\/td>\n<\/tr>\n<tr>\n<td>&lt;len&gt; \u8ba1\u6570<\/td>\n<td>10 \u8fdb\u5236 ASCII&#xff0c;\u53ea\u8ba1\u7b97 header \u533a&#xff08;\u4e0d\u542b\u5192\u53f7\u548c\u9017\u53f7&#xff09;\u3002<\/td>\n<\/tr>\n<tr>\n<td>Header \u7f16\u7801<\/td>\n<td>NUL (0x00) \u5206\u9694 key\/value \u5bf9&#xff1b;\u7ed3\u5c3e\u9700\u6709\u989d\u5916\u7684 0x00 \u4f5c\u4e3a\u7ec8\u6b62\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5fc5\u5907\u952e<\/td>\n<td>SCGI&#061;1, CONTENT_LENGTH, REQUEST_METHOD, REQUEST_URI, SERVER_PROTOCOL, SERVER_NAME, SERVER_PORT, REMOTE_ADDR\u2026 &#xff08;\u5b8c\u5168\u6cbf\u88ad CGI \u73af\u5883\u53d8\u91cf\u547d\u540d&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u6b63\u6587\u7f16\u7801<\/td>\n<td>\u4e0d\u505a\u8f6c\u6362&#xff0c;\u6309 CONTENT_TYPE \u7531\u540e\u7aef\u81ea\u884c\u89e3\u6790\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u54cd\u5e94\u683c\u5f0f<\/td>\n<td>\u7eaf HTTP&#xff1a;Status:\u3001Content-Type:\u3001\u81ea\u5b9a\u4e49 Header\u2026 \u8fde\u540c\u7a7a\u884c\u548c body \u4e00\u5e76\u8fd4\u56de\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u9519\u8bef\u95ed\u5305<\/td>\n<td>\u540e\u7aef\u82e5\u76f4\u63a5 close() \u8fde\u63a5&#xff0c;Nginx \u4f1a\u5411\u5ba2\u6237\u7aef\u8fd4\u56de 502 Bad Gateway&#xff1b;\u82e5\u60f3\u8fd4\u56de 5xx&#xff0c;\u53ef\u4e3b\u52a8\u8f93\u51fa Status: 500\\\\r\\\\n\u2026\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Netstring \u89e3\u6790\u793a\u4f8b<\/h4>\n<p>Header \u82e5\u4e3a<\/p>\n<p> CONTENT_LENGTH\\\\x0013\\\\x00SCGI\\\\x001\\\\x00REQUEST_METHOD\\\\x00POST\\\\x00<\/p>\n<p>\u5219\u603b\u5b57\u8282\u4e3a 53&#xff0c;\u9996\u90e8\u5199\u6210 53:&#xff0c;\u4e4b\u540e\u63a5\u9017\u53f7\u5206\u9694\u6b63\u6587\u3002<\/p>\n<h3>2 \u524d\u7aef\u670d\u52a1\u5668\u652f\u6301\u77e9\u9635 &amp; \u91cd\u8981\u6307\u4ee4<\/h3>\n<table>\n<tr>\u524d\u7aef\u652f\u6301\u65b9\u5f0f\u5173\u952e\u6307\u4ee4\/\u6a21\u5757\u7279\u6b8a\u6ce8\u610f<\/tr>\n<tbody>\n<tr>\n<td>Nginx<\/td>\n<td>\u539f\u751f<\/td>\n<td>scgi_pass, scgi_param, scgi_buffers, scgi_cache \u7b49&#xff08;ngx_http_scgi_module&#xff09;<\/td>\n<td>\u4e00\u5b9a include scgi_params&#xff1b;\u53ef\u7528 unix:\/run\/app.sock \u63d0\u5347\u6027\u80fd<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>Apache<\/td>\n<td>mod_proxy_scgi<\/td>\n<td>&#096;ProxyPass &#034;unix:\/tmp\/app.sock<\/td>\n<td>scgi:\/\/localhost\/&#034;&#096;<\/td>\n<td>\u9700\u542f\u7528 mod_proxy &amp; mod_proxy_scgi<\/td>\n<\/tr>\n<tr>\n<td>Caddy 2<\/td>\n<td>\u6838\u5fc3<\/td>\n<td>reverse_proxy unix\/\/run\/app.sock scgi<\/td>\n<td>Caddy \u4f1a\u81ea\u52a8\u8f6c\u6362\u5934\u90e8<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>lighttpd<\/td>\n<td>mod_scgi<\/td>\n<td>scgi.server &#061; (&#034;\/&#034; &#061;&gt; ( &#034;socket&#034; &#061;&gt; &#034;\/tmp\/app.sock&#034; ))<\/td>\n<td>\u65e9\u671f\u7248\u672c\u9ed8\u8ba4\u4e00\u6b21\u8fde\u63a5\u53ea\u8dd1\u4e00\u6b21\u8bf7\u6c42<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>HAProxy<\/td>\n<td>TCP \u76f4\u900f<\/td>\n<td>mode tcp &#043; \u9002\u5f53\u7684 timeout \u914d\u7f6e<\/td>\n<td>\u4ec5\u505a\u56db\u5c42\u8d1f\u8f7d&#xff0c;\u4e0d\u89e3\u6790 SCGI \u5934<\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Nginx \u5e38\u7528 scgi_* \u6307\u4ee4\u8868<\/h4>\n<table>\n<tr>\u6307\u4ee4\u4f5c\u7528\u9ed8\u8ba4\u5efa\u8bae\u503c \/ \u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>scgi_buffers<\/td>\n<td>\u8bbe\u7f6e\u51e0\u4e2a\u7f13\u5b58\u533a\u7f13\u5b58\u4e0a\u6e38\u54cd\u5e94<\/td>\n<td>8 4k<\/td>\n<td>\u5927\u6587\u4ef6\u4e0b\u8f7d\u6539\u6210 16 16k<\/td>\n<\/tr>\n<tr>\n<td>scgi_busy_buffers_size<\/td>\n<td>\u54cd\u5e94\u8fc7\u5927\u65f6\u4e00\u6b21\u6027\u5199\u78c1\u76d8\u7684\u9608\u503c<\/td>\n<td>\u65e0<\/td>\n<td>\u4e0e\u4e0a\u884c buffer \u603b\u548c\u76f8\u540c<\/td>\n<\/tr>\n<tr>\n<td>scgi_read_timeout<\/td>\n<td>\u7b49\u540e\u7aef\u54cd\u5e94\u6700\u5927\u65f6\u95f4<\/td>\n<td>60s<\/td>\n<td>SSE\/\u957f\u8f6e\u8be2\u8c03\u5230 1h<\/td>\n<\/tr>\n<tr>\n<td>scgi_next_upstream<\/td>\n<td>\u53d1\u751f\u54ea\u4e9b\u9519\u8bef\u81ea\u52a8\u91cd\u8bd5<\/td>\n<td>error timeout<\/td>\n<td>\u52a0\u5165 invalid_header http_500 http_502 \u7b49<\/td>\n<\/tr>\n<tr>\n<td>scgi_cache<\/td>\n<td>\u542f\u52a8 Nginx \u5c42\u7f13\u5b58<\/td>\n<td>off<\/td>\n<td>\u9759\u6001\u6216\u5e42\u7b49 GET \u573a\u666f\u53ef\u63d0\u5347 QPS<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3 \u591a\u8bed\u8a00\u5b9e\u73b0\u53c2\u8003<\/h3>\n<h4>3.1 Go&#xff08;\u6807\u51c6\u5e93\u7248\u672c&#xff0c;\u53ef\u5e73\u6ed1\u590d\u7528 net\/http Handler&#xff09;<\/h4>\n<p><span class=\"token comment\">\/\/ go run scgi-http-adapter.go<\/span><br \/>\n<span class=\"token keyword\">package<\/span> main<\/p>\n<p><span class=\"token keyword\">import<\/span> <span class=\"token punctuation\">(<\/span><br \/>\n<span class=\"token string\">&#034;bufio&#034;<\/span><br \/>\n<span class=\"token string\">&#034;io&#034;<\/span><br \/>\n<span class=\"token string\">&#034;log&#034;<\/span><br \/>\n<span class=\"token string\">&#034;net&#034;<\/span><br \/>\n<span class=\"token string\">&#034;net\/http&#034;<\/span><br \/>\n<span class=\"token string\">&#034;strconv&#034;<\/span><br \/>\n<span class=\"token string\">&#034;strings&#034;<\/span><br \/>\n<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">func<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\nln<span class=\"token punctuation\">,<\/span> err <span class=\"token operator\">:&#061;<\/span> net<span class=\"token punctuation\">.<\/span><span class=\"token function\">Listen<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;unix&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\/run\/app.sock&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ \u2605 Unix Socket<\/span><br \/>\n<span class=\"token keyword\">if<\/span> err <span class=\"token operator\">!&#061;<\/span> <span class=\"token boolean\">nil<\/span> <span class=\"token punctuation\">{<\/span> log<span class=\"token punctuation\">.<\/span><span class=\"token function\">Fatal<\/span><span class=\"token punctuation\">(<\/span>err<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">{<\/span><br \/>\nconn<span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">_<\/span> <span class=\"token operator\">:&#061;<\/span> ln<span class=\"token punctuation\">.<\/span><span class=\"token function\">Accept<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">go<\/span> <span class=\"token function\">serve<\/span><span class=\"token punctuation\">(<\/span>conn<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">func<\/span> <span class=\"token function\">serve<\/span><span class=\"token punctuation\">(<\/span>c net<span class=\"token punctuation\">.<\/span>Conn<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">defer<\/span> c<span class=\"token punctuation\">.<\/span><span class=\"token function\">Close<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\nbr <span class=\"token operator\">:&#061;<\/span> bufio<span class=\"token punctuation\">.<\/span><span class=\"token function\">NewReader<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">for<\/span> <span class=\"token punctuation\">{<\/span><br \/>\nsize<span class=\"token punctuation\">,<\/span> err <span class=\"token operator\">:&#061;<\/span> <span class=\"token function\">readSize<\/span><span class=\"token punctuation\">(<\/span>br<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">if<\/span> err <span class=\"token operator\">!&#061;<\/span> <span class=\"token boolean\">nil<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">}<\/span><br \/>\nhdr <span class=\"token operator\">:&#061;<\/span> <span class=\"token function\">make<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token builtin\">byte<\/span><span class=\"token punctuation\">,<\/span> size<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token boolean\">_<\/span><span class=\"token punctuation\">,<\/span> err <span class=\"token operator\">&#061;<\/span> io<span class=\"token punctuation\">.<\/span><span class=\"token function\">ReadFull<\/span><span class=\"token punctuation\">(<\/span>br<span class=\"token punctuation\">,<\/span> hdr<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> err <span class=\"token operator\">!&#061;<\/span> <span class=\"token boolean\">nil<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">if<\/span> b<span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">_<\/span> <span class=\"token operator\">:&#061;<\/span> br<span class=\"token punctuation\">.<\/span><span class=\"token function\">ReadByte<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> b <span class=\"token operator\">!&#061;<\/span> <span class=\"token string\">&#039;,&#039;<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">}<\/span><\/p>\n<p>env <span class=\"token operator\">:&#061;<\/span> <span class=\"token function\">parse<\/span><span class=\"token punctuation\">(<\/span>hdr<span class=\"token punctuation\">)<\/span><br \/>\ncontentLen<span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">_<\/span> <span class=\"token operator\">:&#061;<\/span> strconv<span class=\"token punctuation\">.<\/span><span class=\"token function\">Atoi<\/span><span class=\"token punctuation\">(<\/span>env<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;CONTENT_LENGTH&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\nbody <span class=\"token operator\">:&#061;<\/span> io<span class=\"token punctuation\">.<\/span><span class=\"token function\">LimitReader<\/span><span class=\"token punctuation\">(<\/span>br<span class=\"token punctuation\">,<\/span> <span class=\"token function\">int64<\/span><span class=\"token punctuation\">(<\/span>contentLen<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>req<span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">_<\/span> <span class=\"token operator\">:&#061;<\/span> http<span class=\"token punctuation\">.<\/span><span class=\"token function\">NewRequest<\/span><span class=\"token punctuation\">(<\/span>env<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;REQUEST_METHOD&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> env<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;REQUEST_URI&#034;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> body<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">for<\/span> k<span class=\"token punctuation\">,<\/span> v <span class=\"token operator\">:&#061;<\/span> <span class=\"token keyword\">range<\/span> env <span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token keyword\">if<\/span> strings<span class=\"token punctuation\">.<\/span><span class=\"token function\">HasPrefix<\/span><span class=\"token punctuation\">(<\/span>k<span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;HTTP_&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\nreq<span class=\"token punctuation\">.<\/span>Header<span class=\"token punctuation\">.<\/span><span class=\"token function\">Set<\/span><span class=\"token punctuation\">(<\/span><span class=\"token function\">cgiToHeader<\/span><span class=\"token punctuation\">(<\/span>k<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> v<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\nresp <span class=\"token operator\">:&#061;<\/span> <span class=\"token function\">newBufferedResponse<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\nhttp<span class=\"token punctuation\">.<\/span>DefaultServeMux<span class=\"token punctuation\">.<\/span><span class=\"token function\">ServeHTTP<\/span><span class=\"token punctuation\">(<\/span>resp<span class=\"token punctuation\">,<\/span> req<span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ \u2605 \u590d\u7528\u73b0\u6709 http.Handler<\/span><br \/>\nresp<span class=\"token punctuation\">.<\/span><span class=\"token function\">WriteTo<\/span><span class=\"token punctuation\">(<\/span>c<span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ readSize\/parse\/cgiToHeader\/newBufferedResponse \u89c1\u9644\u5f55\u2026<\/span><\/p>\n<p>\u4f18\u52bf&#xff1a;\u76f4\u63a5\u6302\u4efb\u4f55 net\/http \u751f\u6001&#xff08;Gin\u3001Echo\u3001Chi\u2026&#xff09;\u3002 \u52a3\u52bf&#xff1a;\u7f3a\u5c11\u8fde\u63a5\u6c60\u3001\u8d85\u65f6\u63a7\u5236\u9700\u81ea\u884c\u5305\u88c5&#xff08;\u53ef\u501f\u52a9 context&#xff09;\u3002<\/p>\n<h4>3.2 Python<\/h4>\n<p>pip <span class=\"token function\">install<\/span> flup6<br \/>\npython -m flup.server.scgi &#8211;bind<span class=\"token operator\">&#061;<\/span>\/run\/app.sock myapp:application<\/p>\n<ul>\n<li>flup6 \u517c\u5bb9 WSGI&#xff1b;\u90e8\u7f72 Gunicorn \u65f6\u52a0 -k scgi.<\/li>\n<li>\u6027\u80fd\u9ad8\u4e8e mod_wsgi\/FastCGI&#xff08;\u5c11\u4e00\u5c42\u5e27\u89e3\u6790&#xff09;\u3002<\/li>\n<\/ul>\n<h4>3.3 Rust<\/h4>\n<p><span class=\"token comment\">\/\/ Cargo.toml -&gt; scgi &#061; &#034;0.3&#034;<\/span><br \/>\n<span class=\"token keyword\">use<\/span> <span class=\"token namespace\">scgi<span class=\"token punctuation\">::<\/span><\/span><span class=\"token class-name\">Server<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">fn<\/span> <span class=\"token function-definition function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token class-name\">Server<\/span><span class=\"token punctuation\">::<\/span><span class=\"token function\">bind<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\/run\/app.sock&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">serve<\/span><span class=\"token punctuation\">(<\/span><span class=\"token closure-params\"><span class=\"token closure-punctuation punctuation\">|<\/span>req<span class=\"token closure-punctuation punctuation\">|<\/span><\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token macro property\">format!<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;Status: 200 OK\\\\r\\\\nContent-Type: text\/plain\\\\r\\\\n\\\\r\\\\nHi {}&#034;<\/span><span class=\"token punctuation\">,<\/span> req<span class=\"token punctuation\">.<\/span>path<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">unwrap<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u5b9e\u6d4b TPS&#xff1a;\u4f7f\u7528 Tokio &#043; scgi-async crate&#xff0c;Ryzen 7 5800X \u5355\u6838\u53ef\u8dd1 \u2248130 k req\/s&#xff08;8 KiB \u54cd\u5e94&#xff09;\u3002<\/p>\n<h3>4 \u6027\u80fd\u4e0e\u5bb9\u91cf\u89c4\u5212<\/h3>\n<table>\n<tr>\u5c42\u9762\u5efa\u8bae<\/tr>\n<tbody>\n<tr>\n<td>\u524d\u7aef\u8fde\u63a5\u6570<\/td>\n<td>worker_connections \u00d7 scgi_buffers \u5927\u5c0f \u2248 \u5cf0\u503c\u5e76\u53d1 \u00d7 \u5e73\u5747\u54cd\u5e94\u4f53\u79ef \/ 0.75<\/td>\n<\/tr>\n<tr>\n<td>\u540e\u7aef\u8fdb\u7a0b\u6a21\u578b<\/td>\n<td>CPU \u5bc6\u96c6&#xff1a;\u6bcf\u6838 1 \u8fdb\u7a0b&#xff1b;IO \u5bc6\u96c6&#xff1a;\u6bcf\u6838 \u22652 \u8fdb\u7a0b\u6216\u5f02\u6b65\u6a21\u578b<\/td>\n<\/tr>\n<tr>\n<td>TCP \u4f18\u5316<\/td>\n<td>\u540e\u7aef\u76d1\u542c SO_REUSEPORT&#xff1b;\u5185\u6838\u8c03\u5927 somaxconn&#061;65535\u3001tcp_tw_reuse&#061;1<\/td>\n<\/tr>\n<tr>\n<td>Unix Socket VS TCP<\/td>\n<td>\u672c\u673a\u5efa\u8bae UDS&#xff08;\u5e73\u5747\u7701 10\u201315 \u03bcs RTT\u3001\u65e0\u9700\u68c0\u67e5\u7aef\u53e3\u9632\u706b\u5899&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Bench \u5de5\u5177<\/td>\n<td>wrk -t4 -c200 -d30s &#8211;script&#061;bench.lua http:\/\/127.0.0.1\/&#xff1b;\u6216\u76f4\u63a5 ab\u3001hey<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>5 \u76d1\u63a7\u3001\u65e5\u5fd7\u4e0e\u8bca\u65ad<\/h3>\n<table>\n<tr>\u76d1\u63a7\u9879\u91c7\u96c6\u65b9\u5f0f<\/tr>\n<tbody>\n<tr>\n<td>QPS \/ \u5ef6\u8fdf<\/td>\n<td>Nginx $request_time\u3001$upstream_response_time&#xff1b;Prometheus-Exporter<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u540e\u7aef\u9971\u548c<\/td>\n<td>&#096;netstat -an<\/td>\n<td>grep ESTAB<\/td>\n<td>wc -l&#096;&#xff1b;\u5e94\u7528\u5185\u66b4\u9732 Goroutine\/Thread \u6570<\/td>\n<\/tr>\n<tr>\n<td>5xx \u6bd4\u4f8b<\/td>\n<td>Nginx log_format \u6253\u6807\u7b7e&#xff0c;Grafana \u8d70\u65e5\u5fd7\u805a\u5408<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u8fde\u63a5\u6cc4\u6f0f<\/td>\n<td>\u957f\u8fde\u63a5\u4f46\u65e0\u8bf7\u6c42\u65f6&#xff0c;\u5e94\u5b9a\u671f PING \u6216\u4f7f\u7528 scgi_connect_timeout<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u6293\u5305\u8c03\u8bd5<\/td>\n<td>socat -x -v TCP-LISTEN:9999,fork,reuseaddr,bind&#061;127.0.0.1 UNIX-CONNECT:\/run\/app.sock<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6545\u969c\u5b9a\u4f4d\u601d\u8def<\/p>\n<li>502 \u2192 \u68c0\u67e5\u540e\u7aef\u76d1\u542c \/ \u6743\u9650 \/ SELinux\u3002<\/li>\n<li>\u957f\u8f6e\u8be2\u8d85\u65f6 \u2192 \u8c03\u5927 scgi_read_timeout \u5e76\u786e\u8ba4\u540e\u7aef flusher.Flush()\u3002<\/li>\n<li>POST \u5927\u6587\u4ef6\u65ad\u6d41 \u2192 client_max_body_size &#043; \u540e\u7aef CONTENT_LENGTH \u6b63\u786e\u89e3\u6790\u3002<\/li>\n<h3>6 \u5b89\u5168 &amp; \u591a\u79df\u6237<\/h3>\n<li>\u6700\u5c0f\u66b4\u9732\u9762&#xff1a;Nginx \u2194 \u540e\u7aef\u4f7f\u7528 UDS &#043; chmod 660&#xff1b;TCP \u65f6\u4ec5\u76d1\u542c 127.0.0.1 \/ ::1\u3002<\/li>\n<li>\u8d44\u6e90\u9694\u79bb&#xff1a;Docker \/ systemd-slice&#xff1b;\u9650\u5236 fd\/CPU\/Memory\u3002<\/li>\n<li>\u8bf7\u6c42\u4f53\u5927\u5c0f&#xff1a;\u53cc\u7aef\u9650\u5236&#xff1a;client_max_body_size 10m; &#043; \u4e1a\u52a1\u6821\u9a8c CONTENT_LENGTH\u3002<\/li>\n<li>Header \u6ce8\u5165&#xff1a;Nginx \u9ed8\u8ba4\u4f1a\u628a\u975e\u6cd5\u5b57\u7b26\u5254\u9664&#xff1b;\u540e\u7aef\u4ecd\u9700\u767d\u540d\u5355\u6821\u9a8c\u3002<\/li>\n<li>DoS \u9632\u62a4&#xff1a;limit_req_zone $binary_remote_addr zone&#061;rl:10m rate&#061;20r\/s;\u3002<\/li>\n<li>\u65e5\u5fd7\u8131\u654f&#xff1a;\u5bf9 QUERY_STRING \/ Body \u6309 key \u8fdb\u884c\u201c\u661f\u53f7\u63a9\u7801\u201d\u6216\u54c8\u5e0c\u3002<\/li>\n<h3>7 \u5bb9\u5668\u5316 &amp; CI\/CD<\/h3>\n<table>\n<tr>\u4e3b\u9898\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td>\u955c\u50cf\u5c42\u6b21<\/td>\n<td>FROM golang:1.22-alpine AS build \u2192 go build \u2192 FROM alpine \u4ec5\u62f7\u8d1d\u4e8c\u8fdb\u5236<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u5065\u5eb7\u68c0\u67e5<\/td>\n<td>&#096;HEALTHCHECK CMD wget -qO- &#8211;post-data&#061;\u2018\u2019 http:\/\/localhost\/health<\/td>\n<td><\/td>\n<td>exit 1&#096;<\/td>\n<\/tr>\n<tr>\n<td>\u70ed\u66f4\u65b0<\/td>\n<td>Kubernetes RollingUpdate&#xff1b;\u6216 systemd socket-activation \u914d\u5408\u4e8c\u8fdb\u5236\u91cd\u8f7d<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u914d\u7f6e\u6ce8\u5165<\/td>\n<td>Nginx include \/etc\/nginx\/conf.d\/*.conf;&#xff1b;\u540e\u7aef\u8bfb\u53d6\u73af\u5883\u53d8\u91cf<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>\u591a\u5b9e\u4f8b\u8c03\u5ea6<\/td>\n<td>\u4f7f\u7528 Sidecar \u6a21\u5f0f\u5171\u4eab \/run\/app.sock&#xff1b;\u6216\u524d\u7aef\u8dd1 DaemonSet&#xff0c;Pod \u5185\u672c\u5730\u8c03\u7528<\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>8 \u5e38\u89c1\u5751 &amp; FAQ<\/h3>\n<table>\n<tr>\u75c7\u72b6\u6839\u56e0\u5904\u7406<\/tr>\n<tbody>\n<tr>\n<td>connect() failed (111: Connection refused)<\/td>\n<td>\u540e\u7aef\u672a\u76d1\u542c \/ \u8def\u5f84\u9519<\/td>\n<td>\u68c0\u67e5 scgi_pass unix:\/run\/app.sock \u8def\u5f84 &amp; \u6743\u9650<\/td>\n<\/tr>\n<tr>\n<td>\u8bf7\u6c42\u5de8\u6162\u4f46 CPU \u7a7a\u95f2<\/td>\n<td>Nginx \u2192 \u540e\u7aef socket backlog \u6ee1 \/ \u4e0a\u6e38\u6162<\/td>\n<td>\u8c03 net.core.somaxconn\u3001worker_connections&#xff1b;\u6392\u67e5 DB<\/td>\n<\/tr>\n<tr>\n<td>\u4e0a\u4f20\u6587\u4ef6\u635f\u574f<\/td>\n<td>\u4e8c\u8fdb\u5236 body \u88ab\u5f53\u4f5c\u6587\u672c\u5904\u7406<\/td>\n<td>io.Copy \u4e0d\u505a\u7f16\u7801\u8f6c\u6362&#xff1b;\u7981\u7528 CRLF \u53d8\u6362<\/td>\n<\/tr>\n<tr>\n<td>Header \u4e22\u5931<\/td>\n<td>\u6f0f\u914d scgi_param HTTP_&#8230; $http_&#8230;<\/td>\n<td>\u81ea\u5b9a\u4e49 Header \u9700\u624b\u52a8\u58f0\u660e<\/td>\n<\/tr>\n<tr>\n<td>403 Forbidden (static path)<\/td>\n<td>Nginx location \u91cd\u53e0<\/td>\n<td>location \/static\/ { root \/var\/www; } \u4f18\u5148\u7ea7\u9ad8\u4e8e \/<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>9 \u5ef6\u4f38\u9605\u8bfb\u4e0e\u5de5\u5177<\/h3>\n<li>\u5b98\u65b9\u534f\u8bae&#xff1a;scgi.org&#xff08;\u539f\u8349\u6848\u5b58\u6863&#xff09;\u3002<\/li>\n<li>ngx_http_scgi_module \u6587\u6863&#xff1a;\u8be6\u5217\u5168\u90e8 30&#043; \u6307\u4ee4\u3002<\/li>\n<li>scgi-curl&#xff1a;\u547d\u4ee4\u884c SCGI \u5ba2\u6237\u7aef&#xff0c;\u53ef\u76f4\u63a5 scgi-curl -d &#039;k&#061;v&#039; \/run\/app.sock \/hello.<\/li>\n<li>uWSGI docs \u201cSCGI gateway\u201d&#xff1a;\u5c55\u793a SCGI \u4e0e\u5176\u4ed6\u534f\u8bae\u6865\u63a5\u65b9\u5f0f\u3002<\/li>\n<li>Paper&#xff1a;\u201cNetstrings: A formal network encoding\u201d\u2014\u2014\u7406\u8bba\u6765\u6e90\u3002<\/li>\n<h4>\u7ed3\u8bed<\/h4>\n<ul>\n<li>SCGI \u7684\u5b9a\u4f4d\u662f \u201c\u8db3\u591f\u8f7b &#043; \u7b80\u5355 &#043; \u957f\u8fde\u63a5\u201d&#xff1b;<\/li>\n<li>\u5728 \u672c\u5730 IPC \/ \u540c\u673a\u591a\u8bed\u8a00\u5fae\u670d\u52a1 \u573a\u666f\u4e0b&#xff0c;\u5f80\u5f80\u4f18\u4e8e FastCGI\/HTTP&#xff1b;<\/li>\n<li>\u82e5\u9700\u8981\u66f4\u4e30\u5bcc\u7ba1\u7406\u529f\u80fd&#xff08;\u8fdb\u7a0b\u6c60\u3001\u5e73\u6ed1 reload\u3001\u6307\u6807&#xff09;&#xff0c;\u53ef\u5957 supervisor \/ systemd \/ uwsgi&#xff1b;<\/li>\n<li>\u6309\u672c\u6587\u8def\u7ebf\u5b8c\u6210 PoC \u2192 \u63a5\u5165\u76d1\u63a7 \u2192 \u4f18\u5316\u7f13\u51b2\u533a \u2192 \u4e0a\u7ebf\u5373\u53ef\u8fbe\u5230 10^5 RPS \u7ea7\u522b\u3002<\/li>\n<\/ul>\n<p>\u5982\u9700 \u4ee3\u7801\u5ba1\u9605\u3001Nginx \u9ad8\u7ea7\u8c03\u4f18\u3001K8s YAML \u793a\u4f8b\u6216\u6027\u80fd\u57fa\u51c6\u811a\u672c&#xff0c;\u544a\u8bc9\u6211\u5177\u4f53\u73af\u5883&#xff0c;\u6211\u518d\u7ec6\u5316\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb920\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf26\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86SCGI\u534f\u8bae\u7684\u57fa\u672c\u6982\u5ff5\u3001\u62a5\u6587\u683c\u5f0f\u3001\u524d\u7aef\u670d\u52a1\u5668\u652f\u6301\u60c5\u51b5\u4ee5\u53ca\u591a\u8bed\u8a00\u5b9e\u73b0\u53c2\u8003\u3002SCGI\u534f\u8bae\u91c7\u7528\u957f\u8fde\u63a5\u65b9\u5f0f\uff0c\u901a\u8fc7TCP\/UnixSocket\u4f20\u8f93\u591a\u4e2a\u8bf7\u6c42\uff0c\u62a5\u6587\u683c\u5f0f\u5305\u62ec\u957f\u5ea6\u3001\u5934\u90e8\u548c\u6b63\u6587\uff0c\u5934\u90e8\u4f7f\u7528NUL\u5206\u9694\u952e\u503c\u5bf9\uff0c\u5e76\u6cbf\u88adCGI\u73af\u5883\u53d8\u91cf\u547d\u540d\u3002\u524d\u7aef\u670d\u52a1\u5668\u5982Nginx\u3001Apache\u3001Caddy 2\u3001lighttpd\u548cHAProxy\u5747\u652f\u6301SCGI\u534f\u8bae\uff0c\u4f46\u914d\u7f6e\u65b9\u5f0f\u6709\u6240\u4e0d\u540c\u3002Nginx\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684SCGI\u76f8\u5173\u6307\u4ee4\uff0c\u5982scgi_pass\u3001scgi_param\u7b49\uff0c\u5efa\u8bae\u6839\u636e\u573a\u666f\u8c03\u6574\u7f13\u5b58\u548c\u8d85\u65f6\u8bbe\u7f6e\u3002\u6b64\u5916\uff0c\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86Go\u8bed\u8a00\u7684S<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[993,43,44],"topic":[],"class_list":["post-39141","post","type-post","status-publish","format-standard","hentry","category-server","tag-993","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>SCGI \u670d\u52a1\u5668\u8be6\u89e3 - \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\/39141.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SCGI \u670d\u52a1\u5668\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb920\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf26\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86SCGI\u534f\u8bae\u7684\u57fa\u672c\u6982\u5ff5\u3001\u62a5\u6587\u683c\u5f0f\u3001\u524d\u7aef\u670d\u52a1\u5668\u652f\u6301\u60c5\u51b5\u4ee5\u53ca\u591a\u8bed\u8a00\u5b9e\u73b0\u53c2\u8003\u3002SCGI\u534f\u8bae\u91c7\u7528\u957f\u8fde\u63a5\u65b9\u5f0f\uff0c\u901a\u8fc7TCP\/UnixSocket\u4f20\u8f93\u591a\u4e2a\u8bf7\u6c42\uff0c\u62a5\u6587\u683c\u5f0f\u5305\u62ec\u957f\u5ea6\u3001\u5934\u90e8\u548c\u6b63\u6587\uff0c\u5934\u90e8\u4f7f\u7528NUL\u5206\u9694\u952e\u503c\u5bf9\uff0c\u5e76\u6cbf\u88adCGI\u73af\u5883\u53d8\u91cf\u547d\u540d\u3002\u524d\u7aef\u670d\u52a1\u5668\u5982Nginx\u3001Apache\u3001Caddy 2\u3001lighttpd\u548cHAProxy\u5747\u652f\u6301SCGI\u534f\u8bae\uff0c\u4f46\u914d\u7f6e\u65b9\u5f0f\u6709\u6240\u4e0d\u540c\u3002Nginx\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684SCGI\u76f8\u5173\u6307\u4ee4\uff0c\u5982scgi_pass\u3001scgi_param\u7b49\uff0c\u5efa\u8bae\u6839\u636e\u573a\u666f\u8c03\u6574\u7f13\u5b58\u548c\u8d85\u65f6\u8bbe\u7f6e\u3002\u6b64\u5916\uff0c\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86Go\u8bed\u8a00\u7684S\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/39141.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-22T00:02:12+00:00\" \/>\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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39141.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/39141.html\",\"name\":\"SCGI \u670d\u52a1\u5668\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-22T00:02:12+00:00\",\"dateModified\":\"2025-05-22T00:02:12+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/39141.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/39141.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/39141.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SCGI \u670d\u52a1\u5668\u8be6\u89e3\"}]},{\"@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":"SCGI \u670d\u52a1\u5668\u8be6\u89e3 - \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\/39141.html","og_locale":"zh_CN","og_type":"article","og_title":"SCGI \u670d\u52a1\u5668\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb920\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf26\u6b21\u3002\u672c\u6587\u4ecb\u7ecd\u4e86SCGI\u534f\u8bae\u7684\u57fa\u672c\u6982\u5ff5\u3001\u62a5\u6587\u683c\u5f0f\u3001\u524d\u7aef\u670d\u52a1\u5668\u652f\u6301\u60c5\u51b5\u4ee5\u53ca\u591a\u8bed\u8a00\u5b9e\u73b0\u53c2\u8003\u3002SCGI\u534f\u8bae\u91c7\u7528\u957f\u8fde\u63a5\u65b9\u5f0f\uff0c\u901a\u8fc7TCP\/UnixSocket\u4f20\u8f93\u591a\u4e2a\u8bf7\u6c42\uff0c\u62a5\u6587\u683c\u5f0f\u5305\u62ec\u957f\u5ea6\u3001\u5934\u90e8\u548c\u6b63\u6587\uff0c\u5934\u90e8\u4f7f\u7528NUL\u5206\u9694\u952e\u503c\u5bf9\uff0c\u5e76\u6cbf\u88adCGI\u73af\u5883\u53d8\u91cf\u547d\u540d\u3002\u524d\u7aef\u670d\u52a1\u5668\u5982Nginx\u3001Apache\u3001Caddy 2\u3001lighttpd\u548cHAProxy\u5747\u652f\u6301SCGI\u534f\u8bae\uff0c\u4f46\u914d\u7f6e\u65b9\u5f0f\u6709\u6240\u4e0d\u540c\u3002Nginx\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684SCGI\u76f8\u5173\u6307\u4ee4\uff0c\u5982scgi_pass\u3001scgi_param\u7b49\uff0c\u5efa\u8bae\u6839\u636e\u573a\u666f\u8c03\u6574\u7f13\u5b58\u548c\u8d85\u65f6\u8bbe\u7f6e\u3002\u6b64\u5916\uff0c\u6587\u7ae0\u8fd8\u63d0\u4f9b\u4e86Go\u8bed\u8a00\u7684S","og_url":"https:\/\/www.wsisp.com\/helps\/39141.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-22T00:02:12+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/39141.html","url":"https:\/\/www.wsisp.com\/helps\/39141.html","name":"SCGI \u670d\u52a1\u5668\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-22T00:02:12+00:00","dateModified":"2025-05-22T00:02:12+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/39141.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/39141.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/39141.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"SCGI \u670d\u52a1\u5668\u8be6\u89e3"}]},{"@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\/39141","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=39141"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/39141\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=39141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=39141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=39141"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=39141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}