{"id":242,"date":"2024-03-28T11:24:13","date_gmt":"2024-03-28T03:24:13","guid":{"rendered":"http:\/\/blue.yn.cn\/?p=242"},"modified":"2025-07-29T14:45:24","modified_gmt":"2025-07-29T06:45:24","slug":"nginx%e5%b8%b8%e7%94%a8%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"http:\/\/blue.yn.cn\/?p=242","title":{"rendered":"Nginx\u5e38\u7528\u6a21\u5757"},"content":{"rendered":"<h3>nginx\u5e38\u7528\u6a21\u5757<\/h3>\n<h4>nginx\u76ee\u5f55\u7d22\u5f15<\/h4>\n<p>\u5f53<code>ngx_http_index_module<\/code>\u6a21\u5757\u627e\u4e0d\u5230\u7d22\u5f15\u6587\u4ef6\uff0c\u901a\u5e38\u4f1a\u5c06\u8bf7\u6c42\u4f20\u9012\u7ed9<code>ngx_http_autoindex_module<\/code>\u6a21\u5757\u3002<br \/>\n<code>ngx_http_autoindex_module<\/code>\u6a21\u5757\u5904\u7406\u4ee5\u659c\u6760\u5b57\u7b26('\/')\u7ed3\u5c3e\u7684\u8bf7\u6c42\uff0c\u5e76\u751f\u6210\u76ee\u5f55\u6587\u4ef6<\/p>\n<h5>\u914d\u7f6e\u8bed\u6cd5<\/h5>\n<pre><code class=\"language-bash\"># \u542f\u7528\u6216\u7981\u7528\u76ee\u5f55\u5217\u8868\u8f93\u51fa\uff0con\u5f00\u542f\uff0coff\u5173\u95ed\nsyntax\uff1aautoindex on | off\uff1b\ndefault\uff1aautoindex off\uff1b\ncontext\uff1ahttp,server,location\n# \u6307\u5b9a\u662f\u5426\u5728\u76ee\u5f55\u5217\u8868\u4e2d\u8f93\u51fa\u786e\u5207\u7684\u6587\u4ef6\u5927\u5c0f\uff0con\u663e\u793a\u5b57\u8282\uff0coff\u663e\u793a\u5927\u6982\u5355\u4f4d\nsyntax\uff1aautoindex_exact_size on | off;\ndefault:autoindex_exact_size on;\ncontext:http,server,location\n# \u6307\u5b9a\u76ee\u5f55\u5217\u8868\u4e2d\u7684\u65f6\u95f4\u662f\u5e94\u4ee5\u672c\u5730\u65f6\u533a\u8fd8\u662fUTC\u8f93\u51fa\u3002on\u672c\u5730\u65f6\u533a\uff0coff UTC\u65f6\u95f4\u3002\nsyntax:autoindex_localtime on | off;\ndefault:autoindex_localtime off;\ncontext:http,server,location<\/code><\/pre>\n<h5>\u914d\u7f6e\u793a\u4f8b<\/h5>\n<pre><code class=\"language-bash\">cat \/etc\/nginx\/conf.d\/wordpress.conf\nserver {\n    listen 80;\n    server_name mirror.xxx.net;\n    charset utf-8;  # \u8bbe\u5b9a\u5b57\u7b26\u96c6\uff0c\u9632\u6b62\u4e2d\u6587\u5b57\u7b26\u4e71\u7801\u663e\u793a\n    autoindex on;\n    autoindex_exact_size off;\n    autoindex_localtime on;\n    location \/ {\n        root \/code\/;\n    }\n}<\/code><\/pre>\n<h3>nginx\u8bbf\u95ee\u63a7\u5236<\/h3>\n<p><code>ngx_http_access_module<\/code>\u6a21\u5757\u8fd0\u884c\u9650\u5236\u5bf9\u67d0\u4e9b\u5ba2\u6237\u7aef\u5730\u5740\u7684\u8bbf\u95ee\u3002<\/p>\n<h4>\u914d\u7f6e\u8bed\u6cd5<\/h4>\n<pre><code class=\"language-bash\"># \u5141\u8bb8\u914d\u7f6e\u8bed\u6cd5\nsyntax:allow address | CIDR | unix: | all;\ndefault:-\ncontext:http,server,location,\nlimit_except\n# \u62d2\u7edd\u914d\u7f6e\u8bed\u6cd5\nsyntax:deny address | CIDR | unix: | all;\ndefault:-\ncontext:http,server,location,\nlimit_except<\/code><\/pre>\n<h4>\u914d\u7f6e\u793a\u4f8b<\/h4>\n<ul>\n<li>\n<p>\u53ea\u5141\u8bb8\u6307\u5b9a\u7684\u6765\u6e90ip\u80fd\u8bbf\u95ee<code>\/centos<\/code>\uff0c\u5176\u4ed6\u7f51\u6bb5\u5168\u90e8\u62d2\u7edd<\/p>\n<pre><code class=\"language-bash\">location \/centos {\nallow 127.0.0.1;\nallow 10.0.0.1\/32;  # \u5141\u8bb8\u5730\u5740\u6216\u5730\u5740\u6bb5\ndeny all;  # \u62d2\u7edd\u6240\u6709\u4eba\n}<\/code><\/pre>\n<\/li>\n<li>\n<p>\u62d2\u7edd\u6307\u5b9a\u7684ip\u8bbf\u95ee\u8be5\u7f51\u7ad9\u7684<code>\/centos<\/code>\uff0c\u5176\u4ed6ip\u5168\u90e8\u5141\u8bb8\u8bbf\u95ee<\/p>\n<pre><code class=\"language-bash\">location \/centos {\ndeny 10.0.0.1\/32;  # \u62d2\u7edd\u6307\u5b9a\u7684\u5730\u5740\u6216\u5730\u5740\u6bb5\nallow all;  # \u5141\u8bb8\u6240\u6709\u7684\u5730\u5740\n}<\/code><\/pre>\n<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\uff1adeny\u548callow\u7684\u987a\u5e8f\u662f\u6709\u5f71\u54cd\u7684<\/strong><br \/>\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u4ece\u7b2c\u4e00\u6761\u89c4\u5219\u8fdb\u884c\u5339\u914d<br \/>\n\u5982\u679c\u5339\u914d\u6210\u529f\uff0c\u5219\u4e0d\u7ee7\u7eed\u5339\u914d\u4e0b\u9762\u7684\u5185\u5bb9<br \/>\n\u5982\u679c\u5339\u914d\u4e0d\u6210\u529f\uff0c\u5219\u7ee7\u7eed\u5f80\u4e0b\u5bfb\u627e\u80fd\u5339\u914d\u6210\u529f\u7684\u5185\u5bb9<\/p>\n<h3>nginx\u57fa\u7840\u8ba4\u8bc1<\/h3>\n<p><code>ngx_http_auth_basic_module<\/code>\u6a21\u5757\u8fd0\u884c\u4f7f\u7528<code>http<\/code>\u57fa\u672c\u8eab\u4efd\u9a8c\u8bc1\uff0c\u9a8c\u8bc1\u7528\u6237\u540d\u548c\u5bc6\u7801\u6765\u9650\u5236\u5bf9\u8d44\u6e90\u7684\u8bbf\u95ee<\/p>\n<h4>\u914d\u7f6e\u8bed\u6cd5<\/h4>\n<pre><code class=\"language-bash\"># \u4f7f\u7528http\u57fa\u672c\u8eab\u4efd\u9a8c\u8bc1\u534f\u8bae\u542f\u7528\u7528\u6237\u540d\u548c\u5bc6\u7801\u9a8c\u8bc1\nsyntax:auth_basic string | off;\ndefault:auth_basic off;\ncontext:http,server,location,\nlimit_except\n# \u6307\u5b9a\u4fdd\u5b58\u7528\u6237\u540d\u548c\u5bc6\u7801\u7684\u6587\u4ef6\nsyntax:auth_basic_user_file file;\ndefault:-\ncontext:http,server,location,\nlimit_except<\/code><\/pre>\n<p>\u6307\u5b9a\u4fdd\u5b58\u7528\u6237\u540d\u548c\u5bc6\u7801\u7684\u6587\u4ef6\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-bash\"># \u53ef\u4ee5\u4f7f\u7528htpasswd\u7a0b\u5e8f\u6216&quot;openssl passwd&quot;\u547d\u4ee4\u751f\u6210\u5bf9\u5e94\u7684\u5bc6\u7801\uff1b\nname1:passwd1\nname2:passwd2\n# \u4f7f\u7528htpasswd\u521b\u5efa\u65b0\u7684\u5bc6\u7801\u6587\u4ef6\uff0c-c \u521b\u5efa\u65b0\u6587\u4ef6 -b \u5141\u8bb8\u547d\u4ee4\u884c\u8f93\u5165\u5bc6\u7801\nyum install httpd-tools\nhtpasswd -b -c \/etc\/nginx\/auth_conf xxx 123456<\/code><\/pre>\n<h4>\u914d\u7f6e\u793a\u4f8b<\/h4>\n<pre><code class=\"language-bash\">location \/centos {\n    auth_basic &quot;Auth access Blog Input your Passwd!&quot;;\n    auth_basic_user_file \/etc\/nginx\/auth_conf;\n}<\/code><\/pre>\n<h3>nginx\u9650\u6d41\u9650\u901f<\/h3>\n<h4>\u4e3a\u4ec0\u4e48\u8981\u9650\u901f<\/h4>\n<p>\u9650\u5236\u67d0\u4e2a\u7528\u6237\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\u80fd\u591f\u4ea7\u751f\u7684<code>http<\/code>\u8bf7\u6c42\u3002\u6216\u8005\u8bf4\u9650\u5236\u67d0\u4e2a\u7528\u6237\u7684\u4e0b\u8f7d\u901f\u5ea6\u3002<br \/>\n503\uff1a\u8fc7\u8f7d\u4fdd\u62a4<\/p>\n<h4>\u9650\u901f\u5e94\u7528\u573a\u666f<\/h4>\n<p>\u4e0b\u8f7d\u9650\u901f\uff1a\u9650\u5236\u7528\u6237\u4e0b\u8f7d\u8d44\u6e90\u7684\u901f\u5ea6<br \/>\n<code>ngx_http_core_module<\/code><br \/>\n\u8bf7\u6c42\u9650\u5236\uff1a\u9650\u5236\u7528\u6237\u5355\u4f4d\u65f6\u95f4\u5185\u6240\u4ea7\u751f\u7684<code>http<\/code>\u8bf7\u6c42\u6570<br \/>\n<code>ngx_http_limit_req_module<\/code><br \/>\n\u8fde\u63a5\u9650\u5236\uff1a\u9650\u5236\u540c\u4e00\u65f6\u95f4\u7684\u8fde\u63a5\u6570\uff0c\u5373\u5e76\u53d1\u6570\u9650\u5236<br \/>\n<code>ngx_http_limit_conn_module<\/code><\/p>\n<h4>\u8bf7\u6c42\u9891\u7387\u9650\u901f\u539f\u7406<\/h4>\n<p>\u6c34(\u8bf7\u6c42)\u4ece\u4e0a\u65b9\u5012\u5165\u6c34\u6876\uff0c\u4ece\u6c34\u6876\u4e0b\u65b9\u6d41\u51fa\uff08\u88ab\u5904\u7406\uff09<br \/>\n\u5982\u679c\u8bf4\u8c01\uff08\u8bf7\u6c42\uff09\u6d41\u5165\u7684\u8fc7\u5feb\uff0c\u6c34\u6876\u6d41\u51fa\uff08\u88ab\u5904\u7406\uff09\u7684\u8fc7\u6162\uff0c\u6765\u4e0d\u53ca\u6d41\u51fa\u7684\u6c34\u5b58\u5728\u6c34\u6876\u4e2d\uff08\u7f13\u5b58\uff09\uff0c\u7136\u540e\u4ee5\u56fa\u5b9a\u901f\u7387\u6d41\u51fa\uff0c\u6c34\u6876\u6ee1\u540e\u5219\u6c34\u6ea2\u51fa\uff08\u4e22\u5f03\uff09\u3002<br \/>\n\u7b80\u5355\u6765\u8bf4\u5c31\u662f\uff1a\u5f53\u5904\u7406\u901f\u5ea6\uff0c\u8fbe\u4e0d\u5230\u8bf7\u6c42\u7684\u901f\u5ea6\uff0c\u5219\u4f1a\u5c06\u8bf7\u6c42\u653e\u7f6e\u7f13\u5b58\uff0c\u7136\u540e\u6301\u7eed\u5904\u7406\u3002\u5f53\u7f13\u5b58\u88ab\u5360\u6ee1\uff0c\u5982\u679c\u8fd8\u6709\u5927\u91cf\u7684\u8bf7\u6c42\uff0c\u5219\u4f1a\u88ab\u4e22\u5f03<\/p>\n<h4>\u9650\u5236\u8bf7\u6c42\u5e76\u53d1\u6570<\/h4>\n<ol>\n<li>\n<p>\u6307\u4ee4<\/p>\n<pre><code class=\"language-bash\">syntax:limit_req_zone key zone=name:size rate=rate;\ndefault:-\ncontext:http\nsyntax:limit_req zone number [burst=number][nodelay];\ndefault:-\ncontext:http,server,location<\/code><\/pre>\n<\/li>\n<li>\n<p>\u57fa\u4e8e\u6765\u6e90ip\u5bf9\u4e0b\u8f7d\u901f\u7387\u9650\u5236\uff0c\u9650\u5236\u6bcf\u79d2\u5904\u74061\u6b21\u8bf7\u6c42\uff0c\u4f46\u53ef\u4ee5\u7a81\u53d1\u8d85\u8fc75\u4e2a\u8bf7\u6c42\u653e\u5165\u7f13\u5b58\u533a<\/p>\n<pre><code class=\"language-bash\"># http\u6807\u7b7e\u6bb5\u5b9a\u4e49\u8bf7\u6c42\u9650\u5236\uff0crate\u9650\u5236\u901f\u7387\uff0c\u9650\u5236\u4e00\u79d2\u949f\u6700\u591a\u4e00\u4e2aIP\u8bf7\u6c42\nhttp {\nlimit_req_zone $binary_remote_addr zone=req_one:10m rate=1r\/s;\n}\nserver {\nlisten 80;\nserver_name xxx.net;\n# \u8bf7\u6c42\u8d85\u8fc71r\/s\uff0c\u5269\u4e0b\u7684\u5c06\u88ab\u5ef6\u8fdf\u5904\u7406\uff0c\u8bf7\u6c42\u6570\u8d85\u8fc7burst\u5b9a\u4e49\u7684\u6570\u91cf\uff0c\u5219\u8fd4\u56de503\nlimit_req zone=req_one burst=3 nodelay;\nlocation \/ {\n    root \/code;\n    index index.html;\n}\n}\nlimit_req_zone $binary_remote_addr zone=req_one:10m rate=1r\/s;\n# \u7b2c\u4e00\u4e2a\u53c2\u6570\uff1a$binary_remote_addr\u8868\u793a\u901a\u8fc7\u8fd9\u4e2a\u6807\u8bc6\u6765\u505a\u9650\u5236\uff0c\u9650\u5236\u540c\u4e00\u5ba2\u6237\u7aefip\u5730\u5740\n# \u7b2c\u4e8c\u4e2a\u53c2\u6570\uff1azone-req_one:10m\u8868\u793a\u751f\u6210\u4e00\u4e2a\u5927\u5c0f\u4e3a10M\uff0c\u540d\u4e3areq_one\u7684\u5185\u5b58\u533a\u57df\uff0c\u7528\u6765\u5b58\u50a8\u8bbf\u95ee\u7684\u9891\u6b21\u4fe1\u606f\n# \u7b2c\u4e09\u4e2a\u53c2\u6570\uff1arate-1r\/s\u8868\u793a\u5141\u8bb8\u76f8\u540c\u6807\u8bc6\u7684\u5ba2\u6237\u7aef\u7684\u8bbf\u95ee\u9891\u6b21\uff0c\u8fd9\u91cc\u9650\u5236\u7684\u662f\u6bcf\u79d21\u6b21\nlimit_req zone=req_one burst=3 nodelay;\n# \u7b2c\u4e00\u4e2a\u53c2\u6570\uff1azone=req_one \u8bbe\u7f6e\u4f7f\u7528\u54ea\u4e2a\u533a\u57df\u8d56\u505a\u9650\u5236\uff0c\u4e0e\u4e0a\u9762limit_req_zone\u91cc\u7684name\u5bf9\u5e94\n# \u7b2c\u4e8c\u4e2a\u53c2\u6570\uff1aburst=3\uff0c\u8bbe\u7f6e\u4e00\u4e2a\u5927\u5c0f\u4e3a3\u7684\u7f13\u51b2\u533a\uff0c\u5f53\u6709\u5927\u91cf\u8bf7\u6c42\u8fc7\u6765\u65f6\uff0c\u8d85\u8fc7\u4e86\u8bbf\u95ee\u9891\u6b21\u9650\u5236\u7684\u8bf7\u6c42\u53ef\u4ee5\u5148\u653e\u5230\u8fd9\u4e2a\u7f13\u51b2\u533a\u5185\n# \u7b2c\u4e09\u4e2a\u53c2\u6570\uff1anodelay\uff0c\u8d85\u8fc7\u8bbf\u95ee\u9891\u6b21\u5e76\u4e14\u7f13\u51b2\u533a\u4e5f\u6ee1\u4e86\u7684\u65f6\u4f1a\uff0c\u5219\u4f1a\u8fd4\u56de503\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\uff0c\u5219\u6240\u6709\u8bf7\u6c42\u4f1a\u7b49\u5f85\u6392\u961f\u3002<\/code><\/pre>\n<\/li>\n<\/ol>\n<h4>\u9650\u5236\u5e76\u53d1\u8fde\u63a5\u6570<\/h4>\n<ol>\n<li>\n<p>\u6307\u4ee4<\/p>\n<pre><code class=\"language-bash\">syntax:limit_conn_zone key zone=name:size;\ndefault:-\ncontext:http\nsyntax:limit_conn zone number;\ndefault:-\ncontext:http,server,location<\/code><\/pre>\n<\/li>\n<li>\n<p>\u8bbe\u7f6e\u5171\u4eab\u5185\u5b58\u533a\u57df\u548c\u7ed9\u5b9a\u952e\u503c\u7684\u6700\u5927\u5141\u8bb8\u8fde\u63a5\u6570\u3002\u8d85\u8fc7\u6b64\u9650\u5236\u65f6\uff0c\u670d\u52a1\u5668\u5c06\u8fd4\u56de503\u9519\u8bef\u4ee5\u56de\u590d\u8bf7\u6c42<\/p>\n<pre><code class=\"language-bash\">limit_conn_zone $binary_remote_addr zone=conn_od:10m;\nserver {\nlimit_conn conn_od 2;\n}<\/code><\/pre>\n<\/li>\n<\/ol>\n<h4>\u9650\u5236\u4e0b\u8f7d\u901f\u5ea6<\/h4>\n<pre><code class=\"language-bash\">server {\n    limit_rate_after 100m;  # \u8fbe\u5230100m\u5f00\u59cb\u9650\u901f\n    limit_rate 100k;\n}<\/code><\/pre>\n<h4>\u7efc\u5408\u573a\u666f\u5b9e\u8df5<\/h4>\n<ol>\n<li>\u9650\u5236web\u670d\u52a1\u5668\u8bf7\u6c42\u6570\u5904\u7406\u4e3a1\u79d2\u4e00\u4e2a\uff0c\u89e6\u53d1\u503c\u4e3a5\uff0c\u9650\u5236\u7528\u6237\u4ec5\u53ef\u540c\u65f6\u4e0b\u8f7d\u4e00\u4e2a\u6587\u4ef6<\/li>\n<li>\u5f53\u4e0b\u8f7d\u8d85\u8fc7100M\u5219\u9650\u5236\u4e0b\u8f7d\u901f\u5ea6\u4e3a500K<\/li>\n<li>\u5982\u679c\u540c\u65f6\u4e0b\u8f7d\u8d85\u8fc72\u4e2a\u89c6\u9891\uff0c\u5219\u8fd4\u56de\u63d0\u793a\u201c\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u8fdb\u884c\u4f1a\u5458\u91cd\u7f6e\u201d | \u8df3\u8f6c\u5230\u5176\u4ed6\u9875\u9762<\/li>\n<\/ol>\n<pre><code class=\"language-bash\">limit_req_zone $binary_remote_addr zone=req_od:10m rate=1r\/s;\nlimit_conn_zone $binary_remote_addr zone=conn_od:10m;\nserver {\n    listen 80;\n    server_name xxx.net;\n    limit_req zone=req_od burst=5 nodelay;\n    lilmit_conn conn_od 1;\n    limit_rate_after 100m;\n    limit_rate 500k;\n    error_page 503 @errpage;\n    location @errpage {\n        defalt_type text\/html;\n        return 200 &#039;\u63d0\u793a--&gt;\u8bf7\u8054\u7cfb\u7ba1\u7406\u5458\u8fdb\u884c\u4f1a\u8bae\u5145\u503c&#039;;\n        return 302 https:\/\/www.qq.com;\n    }\n    location \/ {\n        index index.html;\n    }\n}<\/code><\/pre>\n<h3>nginx\u72b6\u6001\u76d1\u63a7<\/h3>\n<p><code>ngx_http_stub_status_module<\/code>\u6a21\u5757\u63d0\u4f9b\u5bf9\u57fa\u672c\u72b6\u6001\u4fe1\u606f\u7684\u8bbf\u95ee<br \/>\n\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u96c6\u6210\u8be5\u6a21\u5757\uff0c\u9700\u8981\u4f7f\u7528<code>--with-http_stub_status_module<\/code>\u96c6\u6210<\/p>\n<h4>\u914d\u7f6e\u8bed\u6cd5<\/h4>\n<pre><code class=\"language-bash\">syntax:stub_status;\ndefault:-\ncontext:server,location<\/code><\/pre>\n<h4>\u914d\u7f6e\u793a\u4f8b<\/h4>\n<pre><code class=\"language-bash\">server {\n    listen 80;\n    server_name xxx.net;\n    access_log off;\n    location \/nginx_status {\n        stub_status;\n    }\n}<\/code><\/pre>\n<h4>\u9875\u9762\u72b6\u6001<\/h4>\n<pre><code class=\"language-bash\">Active connections:291\nserver accepts handled requests\n200 200 301\nreading:6 writing:179 waiting:106\n# active connections:\u5f53\u524d\u6d3b\u8dc3\u8fde\u63a5\u6570\uff0c\u5305\u62ecwaiting\u7b49\u5f85\u8fde\u63a5\u6570\n# accepts\uff1a\u5df2\u63a5\u6536\u7684\u603btcp\u8fde\u63a5\u6570\u91cf\n# handled\uff1a\u5df2\u5904\u7406\u7684tcp\u8fde\u63a5\u6570\u91cf\n# requests\uff1a\u5f53\u524d\u603bhttp\u8bf7\u6c42\u6570\u91cf\n# reading\uff1a\u5f53\u524d\u8bfb\u53d6\u7684\u8bf7\u6c42\u5934\u6570\u91cf\n# writing\uff1a\u5f53\u524d\u54cd\u5e94\u7684\u8bf7\u6c42\u5934\u6570\u91cf\n# waiting\uff1a\u5f53\u524d\u7b49\u5f85\u8bf7\u6c42\u7684\u7a7a\u95f2\u5ba2\u6237\u7aef\u8fde\u63a5\u6570<\/code><\/pre>\n<ul>\n<li>\u5982\u4f55\u7406\u89e3<code>reading\u3001writing\u3001waiting<\/code><\/li>\n<li>\u5047\u8bbe\u73b0\u5728\u6709\u4e24\u6761\u8239\u5206\u522b\u4e3a<code>C\u3001S<\/code>\u3002C\u8239\u9700\u8981S\u8239\u76841\u4e2a\u7269\u54c1\uff0c\u90a3\u4e48\u6b64\u65f6C\u8239\u5c31\u8981\u7ed9S\u8239\u53d1\u9001\u4e00\u4e2a\u6d88\u606f\n<ul>\n<li>S\u8239\u6536\u5230\u8fd9\u4e2a\u6d88\u606f\u65f6\u5c31\u662f<code>reading<\/code><\/li>\n<li>S\u8239\u5c06\u7269\u8d44\u53d1\u9001\u7ed9C\u8239\uff0c\u8fd9\u4e2a\u65f6\u5019\u5c31\u662f<code>writing<\/code><\/li>\n<li>\u5982\u679cC\u8239\u9700\u8981S\u8239\u5f88\u591a\u7269\u54c1\uff0c\u90a3\u4e48\u9700\u8981C\u8239\u548cS\u8239\u5efa\u7acb\u8d77\u4e00\u4e2a\u7269\u8d44\u4f20\u9001\u7ba1\u9053\uff0c\u4e0d\u65ad\u7684\u4f20\u9001\u7269\u8d44\u3002\u8fd9\u4e2a\u7ba1\u9053\u5efa\u7acb\u8d77\u6765\u7684\u65f6\u5019\uff0c\u5c31\u662f<code>waiting<\/code>\u72b6\u6001\u4e86<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>nginx\u8d44\u6e90\u7f13\u5b58<\/h3>\n<ul>\n<li>\u6d4f\u89c8\u5668\u7f13\u5b58\u8bbe\u7f6e\u7528\u4e8e\u63d0\u9ad8\u7f51\u7ad9\u6027\u80fd\uff0c\u5c24\u5176\u662f\u65b0\u95fb\u7f51\u7ad9\uff0c\u56fe\u7247\u4e00\u65e6\u53d1\u5e03\uff0c\u6539\u52a8\u7684\u53ef\u80fd\u662f\u975e\u5e38\u5c0f\u7684\u3002\u6240\u4ee5\u6211\u4eec\u5e0c\u671b\u80fd\u5426\u7528\u6237\u8bbf\u95ee\u4e00\u6b21\u540e\uff0c\u56fe\u7247\u7f13\u5b58\u5728\u7528\u6237\u7684\u6d4f\u89c8\u5668\u957f\u65f6\u95f4\u7f13\u5b58\u3002<\/li>\n<li>\u6d4f\u89c8\u5668\u662f\u6709\u81ea\u5df1\u7684\u7f13\u5b58\u673a\u5236\uff0c\u5b83\u662f\u57fa\u4e8e<code>http<\/code>\u534f\u8bae\u7f13\u5b58\u673a\u5236\u6765\u5b9e\u73b0\u7684\uff0c\u5728<code>http<\/code>\u534f\u8bae\u4e2d\u6709\u5f88\u591a\u5934\uff08Headers\uff09\u4fe1\u606f\uff0c\u90a3\u4e48\u5b9e\u73b0\u6d4f\u89c8\u5668\u7684\u7f13\u5b58\u5c31\u9700\u8981\u4ee5\u6765\u7279\u6b8a\u7684\u5934\u4fe1\u606f\u6765\u4e0e\u670d\u52a1\u5668\u8fdb\u884c\u7279\u6b8a\u7684\u9a8c\u8bc1\uff0c\u5982\uff1a<code>Expires\uff08http\/1.0),Cache-control(http\/1.1)<\/code><br \/>\n<h4>\u6d4f\u89c8\u5668\u65e0\u7f13\u5b58<\/h4>\n<h4>\u6d4f\u89c8\u5668\u6709\u7f13\u5b58<\/h4>\n<h4>\u7f13\u5b58\u8fc7\u671f\u6821\u9a8c<\/h4>\n<\/li>\n<li>\u6d4f\u89c8\u5668\u7f13\u5b58\u8fc7\u671f\u6821\u9a8c\u68c0\u67e5\u673a\u5236\uff0c\u8bf4\u660e\u5982\u4e0b\uff1a\n<ul>\n<li>\u6d4f\u89c8\u5668\u8bf7\u6c42\u670d\u52a1\u5668\u4f1a\u5148\u8fdb\u884c<code>expires\u3001cache-control<\/code>\u7684\u68c0\u67e5\uff0c\u68c0\u67e5\u7f13\u5b58\u662f\u5426\u8fc7\u671f\uff0c\u5982\u679c\u6ca1\u6709\u8fc7\u671f\u5219\u76f4\u63a5\u4ece\u7f13\u5b58\u6587\u4ef6\u4e2d\u8bfb\u53d6<\/li>\n<li>\u5982\u679c\u7f13\u5b58\u8fc7\u671f\uff0c\u9996\u5148\u68c0\u67e5\u662f\u5426\u5b58\u5728<code>etag<\/code>\uff0c\u5982\u679c\u5b58\u5728\u5219\u5ba2\u6237\u7aef\u4f1a\u5411<code>web<\/code>\u670d\u52a1\u5668\u8bf7\u6c42<code>if-none-match<\/code>\uff0c\u4e0e<code>etag<\/code>\u503c\u8fdb\u884c\u6bd4\u5bf9\uff0c\u7531\u670d\u52a1\u5668\u51b3\u7b56\u8fd4\u56de200\u8fd8\u662f304<\/li>\n<li>\u5982\u679c<code>etag<\/code>\u4e0d\u5b58\u5728\uff0c\u5219\u8fdb\u884c<code>last-modified<\/code>\u68c0\u67e5\uff0c\u5ba2\u6237\u7aef\u4f1a\u5411<code>web<\/code>\u670d\u52a1\u5668\u8bf7\u6c42<code>if-modified-since<\/code>\uff0c\u4e0e<code>last-modified<\/code>\u8fdb\u884c\u5bf9\u6bd4\uff0c\u7531\u670d\u52a1\u5668\u51b3\u7b56\u8fd4\u56de200\u8fd8\u662f304<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>nginx\u8d44\u6e90\u538b\u7f29<\/h3>\n<p><code>nginx<\/code>\u5c06\u53d1\u9001\u81f3\u5ba2\u6237\u7aef\u4e4b\u524d\u7684\u6570\u636e\u8fdb\u884c\u538b\u7f29\uff0c\u7136\u540e\u4f20\u8f93\uff0c\u8fd9\u80fd\u591f\u6709\u6548\u5730\u8282\u7ea6\u5e26\u5bbd\uff0c\u5e76\u63d0\u9ad8\u54cd\u5e94\u901f\u5ea6\uff1b<br \/>\n\u56fe\u7247\uff1a\u4e0d\u9ad8\uff1b\u6587\u672c\uff1a\u6bd4\u8f83\u9ad8<\/p>\n<h4>\u914d\u7f6e\u8bed\u6cd5<\/h4>\n<pre><code class=\"language-bash\"># 1.\u542f\u7528\u6216\u5173\u95edgzip\u538b\u7f29\nsyntax:gzip on | off;\ndefault:gzip off;\ncontext:http,server,location,if in location\n# 2.gzip\u652f\u6301\u7684\u538b\u7f29\u7c7b\u578b\nsyntax:gzip_types mime-type ...;\ndefault:gzip_types text\/html;\ncontext:http,server,location\n# 3.gzip\u538b\u7f29\u6bd4\u7387\uff0c\u538b\u7f29\u7387\u8d8a\u9ad8\uff0ccpu\u6d88\u8017\u8d8a\u5927\nsyntax:gzip_comp_level level;\ndefault:gzip_comp_level 1;\ncontext:http,server,location\n# 4.gzip\u538b\u7f29\u7684\u6700\u5c0f\u6587\u4ef6\uff0c\u5c0f\u4e8e\u8bbe\u7f6e\u7684\u503c\u6587\u4ef6\u5c06\u4e0d\u4f1a\u88ab\u538b\u7f29\uff08\u7531\u201ccontext-length\u201d\u54cd\u5e94\u5934\u5b57\u6bb5\u786e\u5b9a\uff09\nsyntax:gzip_min_length length;\ndefault:gzip_min_length 20;\ncontext:http,server,location\n# 5.gzip\u538b\u7f29\u652f\u6301\u7684\u534f\u8bae\u7248\u672c\nsyntax:gzip_http_version 1.0 | 1.1;\ndefault:gzip_http_version 1.1;\ncontext:http,server,location\n# 6.\u542f\u7528\u538b\u7f29\uff0c\u662f\u5426\u5728\u54cd\u5e94\u62a5\u6587\u9996\u90e8\u63d2\u5165&quot;vary:accept-encoding&quot;\nsyntax:gzip_vary on | off\ndefault:gzip_vary off;\ncontext:http,server,location<\/code><\/pre>\n<h4>\u56fe\u7247\u538b\u7f29\u6848\u4f8b<\/h4>\n<pre><code class=\"language-bash\">server {\n    listen 80;\n    server_name xxx.net;\n    root \/code\/images;\n    location ~* .*\\.(jpg|gif|png)$ {\n        gzip on;\n        gzip_http_version 1.1;\n        gzip_comp_level 2;\n        gzip_min_length 10k;\n        gzip_types image\/jpeg image\/gif image\/png;\n        gzip_vary on;\n    }\n}<\/code><\/pre>\n<h4>\u6587\u4ef6\u538b\u7f29\u6848\u4f8b<\/h4>\n<pre><code class=\"language-bash\">server {\n    listen 80;\n    server_name xxx.net;\n    root \/code\/doc;\n    location ~* .*\\.(txt|pdf)$ {\n        gzip on;\n        gzip_http_version 1.1;\n        gzip_comp_level 2;\n        gzip_min_length 1k;\n        gzip_types text\/plain application\/pdf;\n        gzip_vary on;\n    }\n}<\/code><\/pre>\n<h3>Nginx Location<\/h3>\n<h4>\u4ec0\u4e48\u662fLocation<\/h4>\n<p><code>location<\/code>\u7528\u6765\u63a7\u5236\u8bbf\u95ee\u7f51\u7ad9\u7684<code>uri<\/code>\u8def\u5f84<\/p>\n<h4>location\u8bed\u6cd5\u793a\u4f8b<\/h4>\n<pre><code class=\"language-bash\">location [ = | ~ | ~* | ^~] uri { ... }\nlocation @name { ... }\n\/api\/xxx\/dadas\/dsadsa\n\/apiv1\/dsa\/dsaxx\/sadsa\/\n# \u5339\u914d\u7b26 \u5339\u914d\u89c4\u5219                   \u4f18\u5148\u7ea7\n# =     \u7cbe\u786e\u5339\u914d                     1\n# ^~    \u4ee5\u67d0\u4e2a\u5b57\u7b26\u4e32\u5f00\u5934              2\n# ~     \u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d          3\n# ~*    \u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u6b63\u5219\u5339\u914d        4\n# \/     \u901a\u7528\u5339\u914d\uff0c\u4efb\u4f55\u8bf7\u6c42\u90fd\u4f1a\u5339\u914d\u5230   5<\/code><\/pre>\n<h4>location\u4f18\u5148\u7ea7\u793a\u4f8b<\/h4>\n<pre><code class=\"language-bash\">server {\n     listen 80;\n     server_name xxx.net;\n     location = \/ {\n         default_type text\/html;\n         return 200 &#039;location = \/&#039;;\n     }\n     location \/ {\n         default_type text\/html;\n         return 200 &#039;location \/&#039;;\n     }\n     location \/documents\/ {\n         default_type text\/html;\n         return 200 &#039;location \/documents\/&#039;;\n     }\n     location ^~ \/images\/ {\n         default_type text\/html;\n         return 200 &#039;location ^~ \/images\/&#039;;\n     }\n     location ~* \\.(gif|jpg|jpeg)$ {\n         default_type text\/html;\n         return 200 &#039;location ~* \\.(gif|jpg|jpeg)&#039;;\n     }\n}\n# \u6d4b\u8bd5\u7ed3\u679c\u5982\u4e0b\uff08\u5efa\u8bae\u662fcurl\u6d4b\u8bd5\uff09\n1.\u8bf7\u6c42 http:\/\/xxx.net\/\n\u4f1a\u88ab location =\/ \u5339\u914d\n2.\u8bf7\u6c42 http:\/\/xxx.net\/index.html\n\u4f1a\u88ab location \/ \u5339\u914d\n3.\u8bf7\u6c42 http:\/\/xxx.net\/documents\/1.html\n\u4f1a\u88ab location \/documents\/ \u5339\u914d\n4.\u8bf7\u6c42 http:\/\/xxx.net\/images\/1.gif\n\u4f1a\u88ab location ^~ \/images\/ \u5339\u914d\n5.\u8bf7\u6c42 http:\/\/xxx.net\/documents\/1.jpg\n\u4f1a\u88ab location ~* \\.(gif|jpg|jpeg)$ \u5339\u914d<\/code><\/pre>\n<h4>location\u5e94\u7528\u573a\u666f<\/h4>\n<pre><code class=\"language-bash\">server {\n    listen 80;\n    server_name xxx.net;\n    # \u901a\u7528\u5339\u914d\uff0c\u4efb\u4f55\u8bf7\u6c42\u90fd\u4f1a\u5339\u914d\u5230\n    location \/ {\n        root html;\n        index index.html;\n    }\n    # \u7cbe\u786e\u5339\u914d\uff0c\u5fc5\u987b\u8bf7\u6c42\u7684uri\u662f\/nginx_status\n    location = \/nginx_status {\n        stub_status;\n    }\n    # \u4e25\u683c\u533a\u5206\u5927\u5c0f\u5199\uff0c\u5339\u914d\u4ee5.php\u7ed3\u5c3e\u7684\u90fd\u8d70\u8fd9\u4e2alocation\n    location ~ \\.php$ {\n        default_type text\/html;\n        return 200 &#039;php\u8bbf\u95ee\u6210\u529f&#039;;\n    }\n    # \u4e25\u683c\u533a\u5206\u5927\u5c0f\u5199\uff0c\u5339\u914d\u4ee5.jsp\u7ed3\u5c3e\u7684\u90fd\u8d70\u8fd9\u4e2alocation\n    location ~ \\.jsp$ {\n        default_type text\/html;\n        return 200 &#039;jsp\u8bbf\u95ee\u6210\u529f&#039;;\n    }\n    # \u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u53ea\u8981\u7528\u6237\u8bbf\u95ee.jpg,gif,pnp,js,css \u90fd\u8d70\u8fd9\u4e2alocation\n    location {\n        # return 403;\n        expires 3d;\n    }\n    # \u4e0d\u533a\u5206\u5927\u5c0f\u5199\u5339\u914d\n    location ~* \\.(sql|bak|tgz|tar.gz|git)$ {\n        deny all;\n    }\n}<\/code><\/pre>\n<h4>location @\u91cd\u5b9a\u5411<\/h4>\n<ul>\n<li><code>location @name<\/code>\u8fd9\u6837\u7684<code>location<\/code>\u4e0d\u7528\u4e8e\u5e38\u89c4\u8bf7\u6c42\u5904\u7406\uff0c\u800c\u662f\u7528\u4e8e\u8bf7\u6c42\u91cd\u5b9a\u5411\n<pre><code class=\"language-bash\">server {\n# \u5982\u679c\u51fa\u73b0\u5f02\u5e38\uff0c\u5219\u91cd\u65b0\u5b9a\u5411\u5230@error_404\u8fd9\u4e2alocation\u4e0a\nerror_page 404 @error_404;\nlocation @error_404 {\n    default_type text\/html;\n    return 200 &#039;\u4f60\u53ef\u80fd\u662f\u4e0d\u5c0f\u5fc3\u8d70\u4e22\u4e86\u3002&#039;;\n}\n}<\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>Nginx\u65e5\u5fd7\u6a21\u5757<\/h3>\n<p><code>nginx<\/code>\u7684\u65e5\u5fd7\u8bb0\u5f55\u975e\u5e38\u7075\u6d3b\uff0c\u53ef\u4ee5\u901a\u8fc7<code>log_format<\/code>\u6765\u5b9a\u4e49\u683c\u5f0f<\/p>\n<h4>nginx\u65e5\u5fd7\u683c\u5f0f<\/h4>\n<p><code>log_format<\/code>\u5b9a\u4e49\u65e5\u5fd7\u683c\u5f0f\u8bed\u6cd5<\/p>\n<pre><code class=\"language-bash\"># \u914d\u7f6e\u8bed\u6cd5\uff1a\u5305\u62ec error.log access.log\nsyntax:log_format name\n[escape=default|json] string ...;\ndefault:log_format combined &quot;...&quot;;\ncontext:http\n# \u9ed8\u8ba4nginx\u5b9a\u4e49\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\nlog_format main &#039;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#039;\n                      &#039;$status $body_bytes_sent &quot;$http_referer&quot; &#039;\n                      &#039;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#039;;\naccess_log\n\/var\/log\/nginx\/access.log main;<\/code><\/pre>\n<p><code>nginx<\/code>\u65e5\u5fd7\u683c\u5f0f\u4e2d\u5e38\u7528\u7684\u53d8\u91cf<\/p>\n<pre><code class=\"language-bash\">$remote_addr          # \u8bb0\u5f55\u5ba2\u6237\u7aefip\u5730\u5740\n$remote_user          # \u8bb0\u5f55\u5ba2\u6237\u7aef\u7528\u6237\u540d\n$time_local           # \u8bb0\u5f55\u901a\u7528\u7684\u672c\u5730\u65f6\u95f4\n$time_iso8601         # \u8bb0\u5f55ISO8601\u6807\u51c6\u683c\u5f0f\u4e0b\u7684\u672c\u5730\u65f6\u95f4\n$request              # \u8bb0\u5f55\u8bf7\u6c42\u7684\u65b9\u6cd5\u4ee5\u53ca\u8bf7\u6c42\u7684http\u534f\u8bae\n$status               # \u8bb0\u5f55\u8bf7\u6c42\u72b6\u6001\u7801\uff08\u7528\u4e8e\u5b9a\u4f4d\u9519\u8bef\u4fe1\u606f\uff09\n$body_bytes_sent      # \u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u7684\u8d44\u6e90\u5b57\u8282\u6570\uff0c\u4e0d\u5305\u62ec\u54cd\u5e94\u5934\u7684\u5927\u5c0f\n$bytes_sent           # \u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\u7684\u603b\u5b57\u8282\u6570\n$msec                 # \u65e5\u5fd7\u5199\u5165\u65f6\u95f4\uff0c\u5355\u4f4d\u4e3a\u79d2\uff0c\u7cbe\u5ea6\u662f\u6beb\u79d2\n$http_referer         # \u8bb0\u5f55\u4ece\u54ea\u4e2a\u9875\u9762\u94fe\u63a5\u8bbf\u95ee\u8fc7\u6765\u7684\n$http_user_agnet      # \u8bb0\u5f55\u5ba2\u6237\u7aef\u6d4f\u89c8\u5668\u76f8\u5173\u4fe1\u606f\n$http_x_forwarded_for # \u8bb0\u5f55\u5ba2\u6237\u7aefip\u5730\u5740\n$request_length       # \u8bf7\u6c42\u7684\u957f\u5ea6\uff08\u5305\u62ec\u8bf7\u6c42\u884c\uff0c\u8bf7\u6c42\u5934\u548c\u8bf7\u6c42\u6b63\u6587\uff09\n$request_time         # \u8bf7\u6c42\u82b1\u8d39\u7684\u65f6\u95f4\uff0c\u5355\u4f4d\u4e3a\u79d2\uff0c\u7cbe\u5ea6\u662f\u6beb\u79d2\n# \u6ce8\uff1a\u5982\u679cnginx\u4f4d\u4e8e\u8d1f\u8f7d\u5747\u8861\u5668\uff0cnginx\u53cd\u5411\u4ee3\u7406\u4e4b\u540e\uff0cweb\u670d\u52a1\u5668\u65e0\u6cd5\u76f4\u63a5\u83b7\u53d6\u5230\u5ba2\u6237\u7aef\u771f\u5b9e\u7684ip\u5730\u5740\n# $remote_addr\u83b7\u53d6\u7684\u662f\u53cd\u5411\u4ee3\u7406\u7684ip\u5730\u5740\uff0c\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\u5728\u8f6c\u53d1\u8bf7\u6c42\u7684http\u5934\u4fe1\u606f\u4e2d\n# \u589e\u52a0x-forwarded-for\u4fe1\u606f\uff0c\u7528\u6765\u8bb0\u5f55\u5ba2\u6237\u7aefip\u5730\u5740\u548c\u5ba2\u6237\u7aef\u8bf7\u6c42\u7684\u670d\u52a1\u5668\u5730\u5740<\/code><\/pre>\n<h4>nginx\u8bbf\u95ee\u65e5\u5fd7<\/h4>\n<ol>\n<li>\n<p><code>web<\/code>\u670d\u52a1\u5668\u7684\u8bbf\u95ee\u65e5\u5fd7\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u65e5\u5fd7\u6765\u5206\u6790\u7528\u6237\u7684\u8bbf\u95ee\u60c5\u51b5\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u65e5\u5fd7\u53d1\u73b0\u4e00\u4e9b\u5f02\u5e38\u8bbf\u95ee\u3002<code>access_log<\/code>\u65e5\u5fd7\u914d\u7f6e\u8bed\u6cd5<\/p>\n<pre><code class=\"language-bash\">syntax:access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];\naccess log off;\ndefault:access_log logs\/access.log combined;\ncontext:http,server,location,if in location,limit_except\nhttp {\naccess_log \/var\/log\/nginx\/access.log main;\nserver{\n    access_log \/var\/log\/nginx\/xxx.net.log main;\n}\n}<\/code><\/pre>\n<\/li>\n<li>\n<p><code>nginx<\/code>\u8bbf\u95ee\u65e5\u5fd7\u914d\u7f6e\u793a\u4f8b<\/p>\n<pre><code class=\"language-bash\">server {\nlisten 80;\nserver_name log.xxx.net;\n# \u5c06\u5f53\u524d\u7684server\u7f51\u7ad9\u7684\u8bbf\u95ee\u65e5\u5fd7\u8bb0\u5f55\u81f3\u5bf9\u5e94\u7684\u76ee\u5f55\uff0c\u4f7f\u7528main\u683c\u5f0f\naccess_log \/var\/log\/nginx\/log.xxx.net.log main;\n}<\/code><\/pre>\n<\/li>\n<\/ol>\n<h4>nginx\u9519\u8bef\u65e5\u5fd7<\/h4>\n<p><code>nginx<\/code>\u5e38\u89c1\u7684\u9519\u8bef\u65e5\u5fd7\u7ea7\u522b\u6709<code>debug | info | notice | warn | error | crit | alert | emerg<\/code>\u7ea7\u522b\u8d8a\u9ad8\u8bb0\u5f55\u7684\u4fe1\u606f\u8d8a\u5c11\uff0c\u5982\u679c\u4e0d\u5b9a\u4e49\uff0c\u9ed8\u8ba4\u7ea7\u522b\u4e3a<code>warn<\/code>\uff0c\u5b83\u53ef\u4ee5\u914d\u7f6e\u5728<code>main\u3001http\u3001server\u3001location<\/code>\u6bb5\u91cc<br \/>\nnginx\u9519\u8bef\u65e5\u5fd7\u793a\u4f8b<\/p>\n<pre><code class=\"language-bash\">error_log \/var\/log\/nginx\/error.log warn;\n# \u5173\u95ed\u9519\u8bef\u65e5\u5fd7\nerror_log \/dev\/null;<\/code><\/pre>\n<h4>nginx\u65e5\u5fd7\u8fc7\u6ee4<\/h4>\n<p>\u4e00\u4e2a\u7f51\u7ad9\u5305\u542b\u5f88\u591a\u5143\u7d20\uff0c\u5c24\u5176\u662f\u6709\u5927\u91cf\u7684<code>images\u3001js\u3001css<\/code>\u7b49\u9759\u6001\u8d44\u6e90\u3002\u8fd9\u6837\u7684\u8bf7\u6c42\u53ef\u4ee5\u4e0d\u7528\u8bb0\u5f55\u65e5\u5fd7<\/p>\n<pre><code class=\"language-bash\"># \u8bf7\u6c42favicon.ico\u65f6\uff0c\u4e0d\u8bb0\u5f55\u65e5\u5fd7\nlocation \/favicon.ico {\n    access_log off;\n    return 200;\n}\n# \u5f53\u6709\u4eba\u8bbf\u95eegif\u3001png\u7b49\u8d44\u6e90\u65f6\uff0c\u5c06\u65e5\u5fd7\u4e22\u5165\u7a7a\nlocation ~* .*\\.(gif|jpg|png|css|js)$ {\n    access_log \/dev\/null;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>nginx\u5e38\u7528\u6a21\u5757 nginx\u76ee\u5f55\u7d22\u5f15 \u5f53ngx_http_index_module\u6a21\u5757\u627e\u4e0d\u5230\u7d22\u5f15\u6587\u4ef6\uff0c\u901a\u5e38\u4f1a&#8230; &raquo; <a class=\"read-more-link\" href=\"http:\/\/blue.yn.cn\/?p=242\">\u9605\u8bfb\u5168\u6587<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-242","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"http:\/\/blue.yn.cn\/index.php?rest_route=\/wp\/v2\/posts\/242","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blue.yn.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blue.yn.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blue.yn.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blue.yn.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=242"}],"version-history":[{"count":12,"href":"http:\/\/blue.yn.cn\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions"}],"predecessor-version":[{"id":2246,"href":"http:\/\/blue.yn.cn\/index.php?rest_route=\/wp\/v2\/posts\/242\/revisions\/2246"}],"wp:attachment":[{"href":"http:\/\/blue.yn.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=242"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blue.yn.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=242"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blue.yn.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=242"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}