{"id":15409,"date":"2024-11-17T20:58:14","date_gmt":"2024-11-17T12:58:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/?p=15409"},"modified":"2024-11-17T20:58:14","modified_gmt":"2024-11-17T12:58:14","slug":"openresty%e4%b8%adngx_lua%e6%a8%a1%e5%9d%97%e6%8f%90%e4%be%9b%e7%9a%84%e6%8c%87%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/15409\/","title":{"rendered":"openResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684\u6307\u4ee4"},"content":{"rendered":"<p>ngx_lua\u6a21\u5757\u7684\u539f\u7406\uff1a<\/p>\n<ol>\n<li>\u6bcf\u4e2aworker\uff08\u5de5\u4f5c\u8fdb\u7a0b\uff09\u521b\u5efa\u4e00\u4e2aLua VM\uff0cworker\u5185\u6240\u6709\u534f\u7a0b\u5171\u4eabVM\uff1b<\/li>\n<li>\u5c06Nginx I\/O\u539f\u8bed\u5c01\u88c5\u540e\u6ce8\u5165 Lua VM\uff0c\u5141\u8bb8Lua\u4ee3\u7801\u76f4\u63a5\u8bbf\u95ee\uff1b<\/li>\n<li>\u6bcf\u4e2a\u5916\u90e8\u8bf7\u6c42\u90fd\u7531\u4e00\u4e2aLua\u534f\u7a0b\u5904\u7406\uff0c\u534f\u7a0b\u4e4b\u95f4\u6570\u636e\u9694\u79bb\uff1b<\/li>\n<li>Lua\u4ee3\u7801\u8c03\u7528I\/O\u64cd\u4f5c\u7b49\u5f02\u6b65\u63a5\u53e3\u65f6\uff0c\u4f1a\u6302\u8d77\u5f53\u524d\u534f\u7a0b\uff08\u5e76\u4fdd\u62a4\u4e0a\u4e0b\u6587\u6570\u636e\uff09\uff0c\u800c\u4e0d\u963b\u585eworker\uff1b<\/li>\n<li>I\/O\u7b49\u5f02\u6b65\u64cd\u4f5c\u5b8c\u6210\u65f6\u8fd8\u539f\u76f8\u5173\u534f\u7a0b\u4e0a\u4e0b\u6587\u6570\u636e\uff0c\u5e76\u7ee7\u7eed\u8fd0\u884c<\/li>\n<\/ol>\n<p><strong>\u7cfb\u5217\u6587\u7ae0\uff1a<\/strong><br \/>\n\u6307\u4ee4\uff1aopenResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684\u6307\u4ee4<br \/>\n\u5e38\u91cf\uff1aopenResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684\u5e38\u91cf<br \/>\nAPI\uff1aopenResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684API<\/p>\n<p>&nbsp;<\/p>\n<h1>\u8981\u5b66\u4f1aopenResty\u5fc5\u987b\u8981\u719f\u8bb0\u7684\u4e00\u5f20\u56fe\uff0c\u719f\u8bb0\uff01\u719f\u8bb0\uff01\uff01\u719f\u8bb0 \uff01\uff01\uff01<\/h1>\n<h1><a href=\"http:\/\/fwq.ai\/wp-content\/uploads\/2017\/11\/77d1c09e-1a37-11e6-97ef-d9767035fc3e.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-15410\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/77d1c09e-1a37-11e6-97ef-d9767035fc3e.png\" width=\"1005\" height=\"910\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/77d1c09e-1a37-11e6-97ef-d9767035fc3e.png 1005w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/77d1c09e-1a37-11e6-97ef-d9767035fc3e-300x272.png 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/77d1c09e-1a37-11e6-97ef-d9767035fc3e-768x695.png 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/77d1c09e-1a37-11e6-97ef-d9767035fc3e-670x607.png 670w\" sizes=\"auto, (max-width: 1005px) 100vw, 1005px\" title=\"openResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684\u6307\u4ee4\u63d2\u56fe\" alt=\"openResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684\u6307\u4ee4\u63d2\u56fe\" \/><\/a><\/h1>\n<h1>\u4e00\u3001\u6307\u4ee4<\/h1>\n<h3><strong>1.1\u00a0<em>lua_capture_error_log<\/em>\u00a0 &lt;\u672a\u77e5&gt;<\/strong><\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_capture_error_log size<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>none<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<h3>1.2 lua_use_default_type<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_use_default_type on | off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_use_default_type on<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<\/em><\/p>\n<p>\u7528\u6765\u542f\u7528\/\u7981\u6b62,ngx_lua\u4f7f\u7528default_type\u6307\u5b9a\u7684Content-Type\u7684\u503c\u3002<\/p>\n<h3>1.3 lua_malloc_trim\u00a0<strong>&lt;\u672a\u77e5&gt;<\/strong><\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_malloc_trim &lt;request-count&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_malloc_trim 1000<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<h3>1.4 lua_code_cache<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_code_cache on | off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_code_cache on<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<\/em><\/p>\n<p>\u542f\u7528\/\u7981\u6b62\u7f13\u5b58\uff0c\u5728<code>*_by_lua_file\u6307\u4ee4\u4e2d\u7684lua\u4ee3\u7801\uff1b\u4f8b\u5982\uff08set_by_lua_file , content_by_lua_file, rewrite_by_lua_file, access_by_lua_fil\uff09<br \/>\n<\/code>\u7f13\u5b58\u5f00\u542f\u65f6\u4fee\u6539LUA\u4ee3\u7801\u9700\u8981\u91cd\u542fnginx,\u4e0d\u5f00\u542f\u65f6\u5219\u4e0d\u7528\u3002\u5f00\u53d1\u9636\u6bb5\u4e00\u822c\u5173\u95ed\u7f13\u5b58\u3002\u751f\u4ea7\u73af\u5883\u5fc5\u9700\u5f00\u542f\uff0c\u5bf9\u6027\u80fd\u7684\u5f71\u54cd\u8f83\u5927\u3002<\/p>\n<h3>1.5 lua_regex_cache_max_entries<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_regex_cache_max_entries &lt;num&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_regex_cache_max_entries 1024<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<p>\u7528\u4e8e\u9650\u5236 \u7f13\u5b58 ngx.re.match, ngx.re.gmatch, ngx.re.sub \u548c ngx.re.gsub\u4e2d\u5e26 -o \u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6570\u91cf\u3002\u5982\u679c\u7f13\u5b58\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u8d85\u8fc7\u8be5\u6570\u91cf\uff0c\u5219\u5728\u65e5\u5fd7\u4e2d\u6709warn\u7684\u65e5\u5fd7\u62a5\u8b66\u3002<\/p>\n<h3>1.6 lua_regex_match_limit\u00a0<strong>&lt;\u672a\u77e5&gt;<\/strong><\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_regex_match_limit &lt;num&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_regex_match_limit 0<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<h3>1.7 lua_package_path<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_package_path &lt;lua-style-path-str&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>The content of LUA_PATH environment variable or Lua\u2019s compiled-in defaults.<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<p>\u7528Lua\u5199\u7684lua\u5916\u90e8\u5e93\u8def\u5f84\uff08.lua\u6587\u4ef6\uff09<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>lua_package_path \"\/data\/www\/openresty\/resty\/?.lua;\/data\/www\/openresty\/lor\/?.lua;;\";<\/pre>\n<p><strong>tips 01 :\u6b64\u5904\u5b9a\u4e49\u4e86lua require\u641c\u7d22.lua\u6587\u4ef6\u7684\u8ddf\u76ee\u5f55\u3002<\/strong><\/p>\n<h3>1.8 lua_package_cpath<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_package_cpath &lt;lua-style-cpath-str&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>The content of LUA_CPATH environment variable or Lua\u2019s compiled-in defaults.<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<p>\u7528C\u5199\u7684lua\u5916\u90e8\u5e93\u8def\u5f84\uff08.so\u6587\u4ef6\uff09<\/p>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre>lua_package_cpath \"\/data\/www\/openresty\/resty\/?.so;\/data\/www\/openresty\/lor\/?.so;;\";<\/pre>\n<p><strong>tips 01 :\u6b64\u5904\u5b9a\u4e49\u4e86lua require\u641c\u7d22.so\u6587\u4ef6\u7684\u8ddf\u76ee\u5f55\u3002<\/strong><\/p>\n<h3>1.9 init_by_lua_block\u3001init_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>init_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong><em>\u00a0init_by_lua_file &lt;path-to-lua-script-file&gt;<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<br \/>\n<\/em><strong>\u8fd0\u884c\u9636\u6bb5:<\/strong>\u00a0<em>loading-config<\/em><\/p>\n<p>master\u8fdb\u7a0b\u542f\u52a8\u65f6\u6302\u8f7d\u7684lua\u4ee3\u7801\u3002<\/p>\n<h3>1.10 init_worker_by_lua_block\u3001init_worker_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>init_worker_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong><em>\u00a0init_worker_by_lua_file &lt;lua-file-path&gt;<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<br \/>\n<\/em><strong>\u8fd0\u884c\u9636\u6bb5:<\/strong>\u00a0<em>starting-worker<\/em><\/p>\n<p>worker\u8fdb\u7a0b\u542f\u52a8\u65f6\u6302\u8f7d\u7684lua\u4ee3\u7801\u3002<\/p>\n<h3>1.11 set_by_lua_block\u3001set_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>set_by_lua_block $res { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>set_by_lua_file $res &lt;path-to-lua-script-file&gt; [$arg1 $arg2 \u2026]<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>server, server if, location, location if<\/em><\/p>\n<p>\u8bbe\u7f6e\u53d8\u91cf\u3002<\/p>\n<h3>1.12 content_by_lua_block\u3001content_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>content_by_lua_block { lua-script }<\/em><strong><br \/>\n\u8bed\u6cd5:<\/strong>\u00a0<em>content_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><strong><br \/>\n\u6a21\u5757:<\/strong>\u00a0<em>location, location if<\/em><\/p>\n<p>\u5185\u5bb9\u5904\u7406\u5668\uff0c\u63a5\u6536\u8bf7\u6c42\u5904\u7406\u5e76\u8f93\u51fa\u54cd\u5e94\uff0ccontent_by_lua_block\u76f4\u63a5\u5728nginx\u914d\u7f6e\u6587\u4ef6\u91cc\u7f16\u5199\u8f83\u77edLua\u4ee3\u7801\u540e\u8005\u4f7f\u7528lua\u6587\u4ef6.<\/p>\n<h3>1.13 rewrite_by_lua_block\u3001rewrite_by_lua_file\u00a0<strong>&lt;\u672a\u77e5&gt;<\/strong><\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>rewrite_by_lua_block { lua-script }<\/em><br \/>\n<strong>\u8bed\u6cd5:<\/strong>\u00a0<em>rewrite_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><br \/>\n<strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<\/em><br \/>\n<strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>rewrite tail<\/em><\/p>\n<p>\u6267\u884c\u5185\u90e8URL\u91cd\u5199\u6216\u8005\u5916\u90e8\u91cd\u5b9a\u5411\uff0c\u5178\u578b\u7684\u5982\u4f2a\u9759\u6001\u5316\u7684URL\u91cd\u5199\u3002\u5176\u9ed8\u8ba4\u6267\u884c\u5728rewrite\u5904\u7406\u9636\u6bb5\u7684\u6700\u540e.<br \/>\n\u6ce8\u610f\uff0c\u5728\u4f7f\u7528rewrite_by_lua_*\u65f6\uff0c\u5f00\u542frewrite_log on;\u540e\u4e5f\u770b\u4e0d\u5230\u76f8\u5e94\u7684rewrite log\u3002<\/p>\n<h3><strong>1.14\u00a0<\/strong>access_by_lua_block\u3001access_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>access_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>access_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>access tail<\/em><\/p>\n<p>\u7528\u4e8e\u8bbf\u95ee\u63a7\u5236\u3002<\/p>\n<h3>1.15 header_filter_by_lua_block\u3001header_filter_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>header_filter_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>header_filter_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>output-header-filter<\/em><\/p>\n<h3>1.16 body_filter_by_lua_block\u3001body_filter_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>body_filter_by_lua_block { lua-script-str }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>body_filter_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>output-body-filter<\/em><\/p>\n<h3>1.17 log_by_lua_block\u3001log_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>log_by_lua_block { lua-script }<\/em><strong><br \/>\n\u8bed\u6cd5:<\/strong>\u00a0<em>log_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<\/em><strong><br \/>\n\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>log<\/em><\/p>\n<h3>1.18 balancer_by_lua_block\u3001balancer_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>balancer_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>balancer_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>upstream<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>content<\/em><\/p>\n<h3>1.19 lua_need_request_body<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_need_request_body &lt;on|off&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>off<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location if<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>depends on usage<\/em><\/p>\n<h3>1.20 ssl_certificate_by_lua_block\u3001ssl_certificate_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>ssl_certificate_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>ssl_certificate_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>server<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>right-before-SSL-handshake<\/em><\/p>\n<h3>1.21 ssl_session_fetch_by_lua_block\u3001ssl_session_fetch_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>ssl_session_fetch_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>ssl_session_fetch_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>right-before-SSL-handshake<\/em><\/p>\n<h3>1.22 ssl_session_store_by_lua_block\u3001ssl_session_store_by_lua_file<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>ssl_session_store_by_lua_block { lua-script }<br \/>\n<\/em><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>ssl_session_store_by_lua_file &lt;path-to-lua-script-file&gt;<\/em><em><br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>right-after-SSL-handshake<\/em><\/p>\n<h3>1.23 lua_shared_dict<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_shared_dict &lt;name&gt; &lt;size&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>no<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<br \/>\n<\/em><strong>\u6267\u884c\u9636\u6bb5:<\/strong>\u00a0<em>depends on usage<\/em><\/p>\n<h3>1.24 lua_socket_connect_timeout\u3001lua_socket_send_timeout\u3001lua_socket_read_timeout<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_connect_timeout &lt;time&gt;<\/em><strong><br \/>\n\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_send_timeout &lt;time&gt;<\/em><strong><br \/>\n\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_read_timeout &lt;time&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_connect_timeout 60s<\/em><strong><br \/>\n\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_send_timeout 60s<\/em><strong><br \/>\n\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_read_timeout 60s<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.25 lua_socket_send_lowat<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_send_lowat &lt;size&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_send_lowat 0<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.26 lua_socket_buffer_size<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_buffer_size &lt;size&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_buffer_size 4k\/8k<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.27 lua_socket_pool_size<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_pool_size &lt;size&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_pool_size 30<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.28 lua_socket_keepalive_timeout<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_keepalive_timeout &lt;time&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_keepalive_timeout 60s<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.29 lua_socket_log_errors<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_socket_log_errors on|off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_socket_log_errors on<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.30 lua_ssl_ciphers<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_ssl_ciphers &lt;ciphers&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_ssl_ciphers DEFAULT<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.31 lua_ssl_crl<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_ssl_crl &lt;file&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>no<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.32 lua_ssl_protocols<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_ssl_protocols [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2]<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.33 lua_ssl_trusted_certificate<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_ssl_trusted_certificate &lt;file&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>no<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.34 lua_ssl_verify_depth<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_ssl_verify_depth &lt;number&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_ssl_verify_depth 1<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location<\/em><\/p>\n<h3>1.35 lua_http10_buffering<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_http10_buffering on|off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_http10_buffering on<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location-if<\/em><\/p>\n<h3>1.36 rewrite_by_lua_no_postpone<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>rewrite_by_lua_no_postpone on|off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>rewrite_by_lua_no_postpone off<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<h3>1.37 access_by_lua_no_postpone<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>access_by_lua_no_postpone on|off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>access_by_lua_no_postpone off<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<h3>1.38 lua_transform_underscores_in_response_headers<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_transform_underscores_in_response_headers on|off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_transform_underscores_in_response_headers on<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location-if<\/em><\/p>\n<h3>1.39 lua_check_client_abort<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_check_client_abort on|off<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_check_client_abort off<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http, server, location, location-if<\/em><\/p>\n<h3>1.40 lua_max_pending_timers<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_max_pending_timers &lt;count&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_max_pending_timers 1024<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n<h3>1.41 lua_max_running_timers<\/h3>\n<p><strong>\u8bed\u6cd5:<\/strong>\u00a0<em>lua_max_running_timers &lt;count&gt;<br \/>\n<\/em><strong>\u9ed8\u8ba4:<\/strong>\u00a0<em>lua_max_running_timers 256<br \/>\n<\/em><strong>\u6a21\u5757:<\/strong>\u00a0<em>http<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ngx_lua\u6a21\u5757\u7684\u539f\u7406\uff1a \u6bcf\u4e2aworker\uff08\u5de5\u4f5c\u8fdb\u7a0b\uff09\u521b\u5efa\u4e00\u4e2aLua VM\uff0cworker\u5185\u6240\u6709\u534f\u7a0b\u5171\u4eabVM\uff1b \u5c06Nginx I\/O\u539f\u8bed\u5c01\u88c5\u540e\u6ce8\u5165 Lua VM\uff0c\u5141\u8bb8Lua\u4ee3\u7801\u76f4\u63a5\u8bbf\u95ee\uff1b \u6bcf\u4e2a\u5916\u90e8\u8bf7\u6c42\u90fd\u7531\u4e00\u4e2aLua\u534f\u7a0b\u5904\u7406\uff0c\u534f\u7a0b\u4e4b\u95f4\u6570\u636e\u9694\u79bb\uff1b Lua\u4ee3\u7801\u8c03\u7528I\/O\u64cd\u4f5c\u7b49\u5f02\u6b65\u63a5\u53e3\u65f6\uff0c\u4f1a\u6302\u8d77\u5f53\u524d\u534f\u7a0b\uff08\u5e76\u4fdd\u62a4\u4e0a\u4e0b\u6587\u6570\u636e\uff09\uff0c\u800c\u4e0d\u963b\u585eworker\uff1b I\/O\u7b49\u5f02\u6b65\u64cd\u4f5c\u5b8c\u6210\u65f6\u8fd8\u539f\u76f8\u5173\u534f\u7a0b\u4e0a\u4e0b\u6587\u6570\u636e\uff0c\u5e76\u7ee7\u7eed\u8fd0\u884c \u7cfb\u5217\u6587\u7ae0\uff1a \u6307\u4ee4\uff1aopenResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684\u6307\u4ee4 \u5e38\u91cf\uff1aopenResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684\u5e38\u91cf API\uff1aopenResty\u4e2dngx_lua\u6a21\u5757\u63d0\u4f9b\u7684API &nbsp; \u8981\u5b66\u4f1aopenResty\u5fc5\u987b\u8981\u719f\u8bb0\u7684\u4e00\u5f20\u56fe\uff0c\u719f\u8bb0\uff01\u719f\u8bb0\uff01\uff01\u719f\u8bb0 \uff01\uff01\uff01 \u4e00\u3001\u6307\u4ee4 1.1\u00a0lua_capture_error_log\u00a0 &lt;\u672a\u77e5&gt; \u8bed\u6cd5:\u00a0lua_capture_error_log size \u9ed8\u8ba4:\u00a0none \u6a21\u5757:\u00a0http 1.2 lua_use_default_type \u8bed\u6cd5:\u00a0lua_use_default_type on | off \u9ed8\u8ba4:\u00a0lua_use_default_type on \u6a21\u5757:\u00a0http, server, location, location if \u7528\u6765\u542f\u7528\/\u7981\u6b62,ngx_lua\u4f7f\u7528default_type\u6307\u5b9a\u7684Content-Type\u7684\u503c\u3002 1.3 lua_malloc_trim\u00a0&lt;\u672a\u77e5&gt; \u8bed\u6cd5:\u00a0lua_malloc_trim &lt;request-count&gt; \u9ed8\u8ba4:\u00a0lua_malloc_trim 1000 \u6a21\u5757:\u00a0http 1.4 lua_code_cache \u8bed\u6cd5:\u00a0lua_code_cache on | off \u9ed8\u8ba4:\u00a0lua_code_cache on \u6a21\u5757:\u00a0http, server, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-15409","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=15409"}],"version-history":[{"count":1,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15409\/revisions"}],"predecessor-version":[{"id":15411,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/15409\/revisions\/15411"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=15409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=15409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=15409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}