{"id":580,"date":"2022-02-17T17:17:46","date_gmt":"2022-02-17T09:17:46","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=580"},"modified":"2022-02-17T18:41:50","modified_gmt":"2022-02-17T10:41:50","slug":"4-nginx%e7%9a%84%e5%b8%b8%e7%94%a8%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=580","title":{"rendered":"4.Nginx\u7684\u5e38\u7528\u6a21\u5757"},"content":{"rendered":"\n<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002\u5fae\u4fe1\uff1as2795802440<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.\u5982\u4f55\u68c0\u67e5nginx\u914d\u7f6e\u4e86\u90a3\u4e9b\u6a21\u5757<\/h2>\n\n\n\n<p>nginx -V<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">2.client_max_body_size\u6a21\u5757<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>client_max_body_size<\/strong>&nbsp;<em>size<\/em>;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>client_max_body_size 1m;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u8bbe\u7f6e\u7528\u6237\u4e0a\u4f20\u6587\u4ef6\u5927\u5c0f\u8bbe<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">3.\u8bbe\u7f6e\u5b57\u7b26\u96c6\uff0c\u907f\u514d\u4e2d\u6587\u4e71\u7801<\/h2>\n\n\n\n<p>charset utf-8\uff1b\uff08\u5b57\u7b26\u96c6\uff0c\u4e00\u822c\u8bbe\u7f6e\u5728main\u5168\u5c40\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">4.\u7f51\u9875\u56fe\u6807\u8bbe\u7f6e\uff08favicon.ico\uff09<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 ~]# cat \/etc\/nginx\/conf.d\/test.conf\nserver {\n\tlisten 80;\n\tlocation \/favicon.ico {\n\t\troot \/code;\n\t\tindex favicon.ico;\n\t}\n}\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"56\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-17.png\" alt=\"\" class=\"wp-image-581\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-17.png 865w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-17-300x19.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-17-768x50.png 768w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">5.autoindex\u76ee\u5f55\u7d22\u5f15\u6a21\u5757\uff08\u7c7b\u4f3c\u963f\u91cc\u6e90\u7684\u754c\u9762\uff09<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>autoindex<\/strong>&nbsp;on&nbsp;|&nbsp;off;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>autoindex off;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u662f\u5426\u5f00\u542f\u76ee\u5f55\u7d22\u5f15<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>autoindex_exact_size<\/strong>&nbsp;on&nbsp;|&nbsp;off;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>autoindex_exact_size on;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u662f\u5426\u4ee5\u4eba\u7c7b\u53ef\u8bfb\u5f62\u5f0f\u663e\u793a\u5927\u5c0f(off), on(\u7cbe\u786e\u663e\u793a\u5b57\u8282)<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>autoindex_format<\/strong>&nbsp;html&nbsp;|&nbsp;xml&nbsp;|&nbsp;json&nbsp;|&nbsp;jsonp;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>autoindex_format html;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u652f\u6301\u7684\u683c\u5f0f\uff0c\u6682\u65f6\u7528\u4e0d\u5230<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>autoindex_localtime<\/strong>&nbsp;on&nbsp;|&nbsp;off;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>autoindex_localtime off;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u662f\u5426\u8c03\u6574\u4e3a\u672c\u5730\u65f6\u95f4\uff0c\u8c03\u6574\uff08on\uff09\uff0c\u4e0d\u8c03\u6574\uff08off\uff09<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 ~]# cat \/etc\/nginx\/conf.d\/autoindex.conf \nserver {\n\tlisten 80;\n\tserver_name autoindex.com;\n\tlocation \/ {\n\t\troot \/code;\n\t\tindex indexx.html;\n\t\tautoindex on;\n\t\tautoindex_exact_size off;\n\t\tautoindex_localtime on;\n\t}\n}\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-18.png\" alt=\"\" class=\"wp-image-582\" width=\"584\" height=\"191\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-18.png 878w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-18-300x98.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-18-768x252.png 768w\" sizes=\"(max-width: 584px) 100vw, 584px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">6.access\u8bbf\u95ee\u63a7\u5236\u6a21\u5757<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>allow<\/strong>&nbsp;<em>address<\/em>&nbsp;|&nbsp;<em>CIDR<\/em>&nbsp;|&nbsp;unix:&nbsp;|&nbsp;all;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code>,&nbsp;<code>limit_except<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u5141\u8bb8\u8bbf\u95ee<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>deny<\/strong>&nbsp;<em>address<\/em>&nbsp;|&nbsp;<em>CIDR<\/em>&nbsp;|&nbsp;unix:&nbsp;|&nbsp;all;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code>,&nbsp;<code>limit_except<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u7981\u6b62\u8bbf\u95ee<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@web01 ~]# cat \/etc\/nginx\/conf.d\/access.conf \nserver {\n\tlisten 80;\n\tserver_name access.com;\n\tlocation \/ {\n\t\tallow 10.0.0.7;####\u53ea\u5141\u8bb810.0.0.7\u8fd9\u4e2aip\u8bbf\u95ee\n\t\tdeny all;###\u62d2\u7edd\u6240\u6709ip\u8bbf\u95ee\n\t\troot \/code;\n\t\tindex indexx.html;\n\t\tautoindex on;\n\t\tautoindex_exact_size off;\n\t\tautoindex_localtime on;\n\t}\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">7.auth_basic\u7528\u6237\u8ba4\u8bc1\u6a21\u5757<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>auth_basic<\/strong>&nbsp;<em>string<\/em>&nbsp;|&nbsp;off;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>auth_basic off;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code>,&nbsp;<code>limit_except<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u662f\u5426\u5f00\u542f\u7528\u6237\u8ba4\u8bc1\u6a21\u5757<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>auth_basic_user_file<\/strong>&nbsp;<em>file<\/em>;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code>,&nbsp;<code>limit_except<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u7528\u6237\u8ba4\u8bc1\u7684\u5bc6\u7801\u6587\u4ef6<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u8ba9\u7528\u6237\u8bbf\u95ee www.sfy.com\/status \u9700\u8981\u8f93\u5165\u7528\u6237\u540d\u548c\u5bc6\u7801\r\n##\u521b\u5efanginx auth_basic_user_file \u9700\u8981\u7684\u5bc6\u7801\u6587\u4ef6\r\nhtpasswd  -b -c \/etc\/nginx\/conf.d\/status.pass sfy 123456\r\n####-b \u5c06\u7528\u6237\u540d\u5bc6\u7801\u5199\u5728\u547d\u4ee4\u884c\uff0c\u975e\u4ea4\u4e92\u5f0f\r\n####-c \u521b\u5efa\u5bc6\u7801\u6587\u4ef6\r\n\u4e0d\u52a0-c\u9ed8\u8ba4\u8ffd\u52a0\u5230\u5bc6\u7801\u6587\u4ef6\u4e0b\u65b9\uff0c\u52a0-c\u4f1a\u8986\u76d6\n&#91;root@web01 ~]# cat \/etc\/nginx\/conf.d\/access.conf \nserver {\n\tlisten 80;\n\tserver_name authbasic.com;\n\tlocation \/ {\n\t\tauth_basic on;\n                auth_basic_user_file auth_basic.pass;\n\t\troot \/code;\n\t\tindex indexx.html;\n\t}\n}\n\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">8.\u5404\u79cd\u9650\u5236\u6a21\u5757<\/h2>\n\n\n\n<p>limit_req \u6a21\u5757 \u9650\u5236\u8bf7\u6c42(http)<br>limit_conn \u6a21\u5757 \u9650\u5236\u8fde\u63a5(tcp)<br>limit_rate \u53bbcore\u6a21\u5757\u627e \u9650\u901f\u5ea6<\/p>\n\n\n\n<p><strong><em>8.1limit_req \u6a21\u5757<\/em><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>limit_req_zone<\/strong>&nbsp;<em>key<\/em>&nbsp;zone=<em>name<\/em>:<em>size<\/em>&nbsp;rate=<em>rate<\/em>&nbsp;[sync];<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code><\/td><\/tr><\/tbody><\/table><figcaption>limit_req_zone #\u521b\u5efa\u6728\u6876\u7a7a\u95f4\u4ee5\u53ca\u6728\u6876\u5904\u7406\u7684\u901f\u7387\uff0c\u4ec5\u653e\u5728http\u5c42<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>limit_req<\/strong>&nbsp;zone=<em>name<\/em>&nbsp;[burst=<em>number<\/em>] [nodelay&nbsp;|&nbsp;delay=<em>number<\/em>];<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>limit_req\u7528\u4e8e\u9650\u5236\u6bcf\u4e2a\u5df2\u5b9a\u4e49\u5bc6\u94a5\u7684\u8bf7\u6c42\u5904\u7406\u901f\u7387\uff0c\u7279\u522b\u662f\u6765\u81ea\u5355\u4e2aIP \u5730\u5740\u7684\u8bf7\u6c42\u7684\u5904\u7406\u901f\u7387\u3002\u9650\u5236\u662f\u4f7f\u7528\u201c\u6f0f\u6876\u201d\u65b9\u6cd5\u5b8c\u6210\u7684<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>http {\r\n\t\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\r\n\tlimit_req_zone $binary_remote_addr zone=one:10m rate=1r\/s;\r\n\t\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\r\n\t#$binary_remote_addr \u7528\u6237ip\u5730\u5740,\u5360\u7528\u7a7a\u95f4\u66f4\u5c11\r\n\t#zone=One:10m  \u6307\u5b9a\u7a7a\u95f4\u540d\u5b57:\u5927\u5c0f\r\n\t#rate=1r\/s  \u6307\u5b9a\u6728\u6876\u5904\u7406\u901f\u5ea6\r\n\t#\u4e0d\u7528$remote_addr\uff0c\u800c\u662f$binary_ remote_addr\u53d8\u91cf\u3002 $binary_remote_addr\u53d8\u91cf\u7684\u5927\u5c0f\u5bf9\u4e8eIPv4\u5730\u5740\u603b\u662f4\u5b57\u8282\uff0c\u5bf9\u4e8eIPv6 \u5730\u5740\u603b\u662f16\u5b57\u8282\r\n\tserver {\n\r\t\u00b7\u00b7\u00b7\u00b7\u00b7\n\t\tlocation \/search\/ {\r\n\t\tlimit_req zone=one burst=5 nodelay;\r\n\t\t#zone=one  #\u6307\u5b9alimit_req_zone \u521b\u5efa\u7684\u6728\u6876\u7a7a\u95f4\uff0c\u5373\u4e0a\u6587\u5b9a\u4e49\u7684zone\r\n\t\t#burst=5  #\u5e76\u53d15\r\n\t\t#\u5e73\u5747\u6bcf\u79d2\u5141\u8bb8\u4e0d\u8d85\u8fc71\u4e2a\u8bf7\u6c42\uff0c\u7a81\u53d1\u8bf7\u6c42\u4e0d\u8d85\u8fc75\u4e2a\r\n\t\t#nodelay #\u9ed8\u8ba4\u4e0d\u52a0\u4e0anodelay,\u8d85\u8fc7\u5e76\u53d1\u6570\u540e,\u6392\u961f(delay) #nodelay\u4e0d\u7b49\u5f85\uff0c\u540c\u65f6\u5904\u7406\uff0c\u8d85\u8fc7\u5e76\u53d1\u6570\u540e,\u62a5\u9519\r\n\t\t}\r\n\t}\r\n}\r\n<\/code><\/pre>\n\n\n\n<p><strong><em>8.2limit_conn\u6a21\u5757<\/em><\/strong><\/p>\n\n\n\n<p>\u57fa\u4e8eip\u9650\u5236\uff0c\u6bcf\u4e2aip\u5730\u5740\u7684\u8fde\u63a5\u6570\u91cf<strong><\/strong><\/p>\n\n\n\n<p>ngx_http_limit_conn\u6a21\u5757\u7528\u4e8e\u9650\u5236\u6bcf\u4e2a\u5df2\u5b9a\u4e49\u5bc6\u94a5\u7684\u8fde\u63a5\u6570\uff0c\u7279\u522b\u662f\u6765\u81ea\u5355\u4e2aIP\u5730\u5740\u7684\u8fde\u63a5\u6570<\/p>\n\n\n\n<p>\u5e76\u975e\u6240\u6709\u8fde\u63a5\u90fd\u88ab\u8ba1\u7b97\u5728\u5185\u3002\u53ea\u6709\u5f53\u4e00\u4e2a\u8fde\u63a5\u6709\u4e00\u4e2a\u6b63\u5728\u7531\u670d\u52a1\u5668\u5904\u7406\u7684\u8bf7\u6c42 \u5e76\u4e14\u6574\u4e2a\u8bf7\u6c42\u5934\u5df2\u7ecf\u88ab\u8bfb\u53d6\u65f6\uff0c\u5b83\u624d\u4f1a\u88ab\u8ba1\u6570<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>limit_conn_zone<\/strong>\u00a0<code><em>key<\/em><\/code>\u00a0<code>zone<\/code>=<code><em>name<\/em><\/code>:<code><em>size<\/em><\/code>;;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>limit_conn<\/strong>&nbsp;<em>zone<\/em>&nbsp;<em>number<\/em>;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>http\u5c42\uff1alimit_conn_zone $binary_remote_addr zone=addr:10m;<\/p>\n\n\n\n<p><strong>server\u5c42\uff1a<\/strong>limit_conn addr 1; \u9650\u5236\u4e00\u4e2a\u8fde\u63a5\uff08\u7528\u6237\u4e0b\u8f7d\uff0c\u9650\u5236\u4e00\u6b21\u53ea\u80fd\u4e0b\u8f7d\u4e00\u4e2a\u8d44\u6e90\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>http {\r\n    limit_conn_zone $binary_remote_addr zone=addr:10m;\r\n    ...\r\n    server {\r\n        ...\r\n        location \/download\/ {\r\n            limit_conn addr 1;\r\n        }<\/code><\/pre>\n\n\n\n<p><strong><em>8.3limit_rate\u6a21\u5757<\/em><\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>limit_rate<\/strong>&nbsp;<em>rate<\/em>;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>limit_rate 0;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code>,&nbsp;<code>if in location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u9650\u5236\u901f\u5ea6<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>limit_rate_after<\/strong>&nbsp;<em>size<\/em>;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>limit_rate_after 0;<\/td><\/tr><tr><th>Context:<\/th><td><code>http<\/code>,&nbsp;<code>server<\/code>,&nbsp;<code>location<\/code>,&nbsp;<code>if in location<\/code><\/td><\/tr><\/tbody><\/table><figcaption>\u8fbe\u5230\u591a\u5c11\u4e4b\u540e\u518d\u9650\u5236\u901f\u5ea6<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>limit_rate_after 50m;\u4e0b\u8f7d\u524d50M\u7684\u8d44\u6e90\u4e0d\u9650\u901f\r\nlimit_rate 200k\uff1b50M\u4e4b\u540e\u9650\u901f200k\r<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">9.stub_status\u72b6\u6001\u6a21\u5757<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>stub_status<\/strong>;<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>location = \/basic_status {\r\n    stub_status;\r\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"593\" height=\"131\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-19.png\" alt=\"\" class=\"wp-image-595\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-19.png 593w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/02\/image-19-300x66.png 300w\" sizes=\"(max-width: 593px) 100vw, 593px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>stub_status<\/td><td>&nbsp;<\/td><\/tr><tr><td>Active connections: 2<\/td><td>#\u5f53\u524d\u6d3b\u52a8\u8fde\u63a5(\u5df2\u7ecf\u8fde\u63a5\u7684\u8fde\u63a5)<\/td><\/tr><tr><td>server accepts<\/td><td>#\u5df2\u7ecf\u63a5\u53d7\u7684\u8fde\u63a5\u8bf7\u6c42(\u603b\u6570)<\/td><\/tr><tr><td>handled<\/td><td>#\u5df2\u7ecf\u5904\u7406\u7684\u8fde\u63a5\u8bf7\u6c42(\u603b\u6570)<\/td><\/tr><tr><td>requests<\/td><td>#\u4e00\u5171\u5411\u6211\u53d1\u9001\u4e86\u591a\u5c11\u8bf7\u6c42(\u603b\u6570)<\/td><\/tr><tr><td>Reading: 0<\/td><td>\u5f53\u524d\u6b63\u5728\u8bfb\u53d6\u7528\u6237\u8bf7\u6c42\u5934\u7684\u6570\u91cf<\/td><\/tr><tr><td>Writing: 1<\/td><td>\u5f53\u524d\u6b63\u53d1\u9001\u54cd\u5e94\u62a5\u6587\u7684\u6570\u91cf<\/td><\/tr><tr><td>Waiting: 1<\/td><td>\u7528\u6237\u7684\u8bf7\u6c42,\u7b49\u5f85\u670d\u52a1\u7aef\u6570\u91cf\uff08\u4fdd\u6301\u957f\u8fde\u63a5\uff0c\u65e0\u8bf7\u6c42\u6b63\u5728\u7b49\u5f85\u65ad\u5f00\u8fde\u63a5\uff09<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">10.location\u5339\u914d\u7684\u4f18\u5148\u7ea7<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Syntax:<\/th><td><code><strong>location<\/strong>&nbsp;[&nbsp;=&nbsp;|&nbsp;~&nbsp;|&nbsp;~*&nbsp;|&nbsp;^~&nbsp;]&nbsp;<em>uri<\/em>&nbsp;{ ... }<\/code><br><code><strong>location<\/strong>&nbsp;@<em>name<\/em>&nbsp;{ ... }<\/code><\/td><\/tr><tr><th>Default:<\/th><td>\u2014<\/td><\/tr><tr><th>Context:<\/th><td><code>server<\/code>,&nbsp;<code>location<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>location = \/ {###\u7cbe\u786e\u5339\u914d\u4f18\u5148\u7ea7\u6700\u9ad8\r\n}\r\n\rlocation ^~ \/document {###\u5339\u914dURL\uff0c\u4e0d\u9002\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u4f18\u5148\u7ea7\u7b2c\u4e8c\n}\nlocation ~ \/documetn {###\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d\u4f18\u5148\u7ea7\u7b2c\u4e09\n}\nlocation ~* \/documetn {###\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d\u4f18\u5148\u7ea7\u7b2c\u4e09\n}\nlocation \/ {###\u901a\u7528\u5339\u914d\uff0c\u5176\u4ed6location\u5339\u914d\u5931\u8d25\uff0c\u9ed8\u8ba4\u5339\u914d\u5230\u8fd9\u91cc\uff0c\u4f18\u5148\u7ea7\u6700\u4f4e\r\r\n}\r\n\r\r<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":246,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/580"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=580"}],"version-history":[{"count":8,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/580\/revisions"}],"predecessor-version":[{"id":598,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/580\/revisions\/598"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/media\/246"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}