{"id":1315,"date":"2025-09-23T09:54:10","date_gmt":"2025-09-23T01:54:10","guid":{"rendered":"https:\/\/www.vcidc.net\/blog\/?p=1315"},"modified":"2025-09-23T09:54:10","modified_gmt":"2025-09-23T01:54:10","slug":"%e5%be%b7%e8%ae%af%e7%94%b5%e8%ae%af%ef%bc%9a%e5%a6%82%e4%bd%95%e5%9c%a8%e6%9c%8d%e5%8a%a1%e5%99%a8%e4%b8%8a%e9%85%8d%e7%bd%ae3mbps%e5%b8%a6%e5%ae%bd%e9%99%90%e5%88%b6%e3%80%90%e6%8e%a8%e8%8d%90","status":"publish","type":"post","link":"https:\/\/www.vcidc.net\/blog\/1315.html","title":{"rendered":"\u5fb7\u8baf\u7535\u8baf\uff1a\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6e3Mbps\u5e26\u5bbd\u9650\u5236\u3010\u63a8\u8350\u3011"},"content":{"rendered":"<p><p>\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u8bb2\u89e3\u5982\u4f55\u5728\u60a8\u7684\u670d\u52a1\u5668\u4e0a\u914d\u7f6e\u4e00\u4e2a3Mbps\u7684\u5e26\u5bbd\u9650\u5236\u3002\u8fd9\u5c06\u901a\u8fc7Nginx\u7684\u6d41\u91cf\u63a7\u5236\u6a21\u5757\u5b9e\u73b0\uff0c\u9002\u7528\u4e8e\u5e0c\u671b\u9650\u5236\u5ba2\u6237\u7aef\u8bf7\u6c42\u901f\u7387\u7684\u573a\u666f\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.vcidc.net\/blog\/wp-content\/uploads\/2025\/07\/OL2L5p.jpg\" alt=\"\u5fb7\u8baf\u7535\u8baf\uff1a\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6e3Mbps\u5e26\u5bbd\u9650\u5236\u3010\u63a8\u8350\u3011\" title=\"\u5fb7\u8baf\u7535\u8baf\uff1a\u5982\u4f55\u5728\u670d\u52a1\u5668\u4e0a\u914d\u7f6e3Mbps\u5e26\u5bbd\u9650\u5236\u3010\u63a8\u8350\u3011\"><\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u524d\u7684\u51c6\u5907<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u5b89\u88c5\u4e86Nginx\uff0c\u5e76\u4e14\u60a8\u6709\u76f8\u5e94\u7684\u6743\u9650\u6765\u4fee\u6539Nginx\u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h2>\u914d\u7f6e3Mbps\u5e26\u5bbd\u9650\u5236<\/h2>\n<\/p>\n<p><h3>1. \u5b89\u88c5Nginx\u6d41\u91cf\u63a7\u5236\u6a21\u5757<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5Nginx\u7684\u6d41\u91cf\u63a7\u5236\u6a21\u5757\u3002\u4ee5\u4e0b\u662f\u5728Ubuntu\u7cfb\u7edf\u4e2d\u5b89\u88c5\u7684\u793a\u4f8b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code>sudo apt-get update<\/p>\r\n<p>sudo apt-get install nginx-full<\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\uff0c\u8bf7\u6839\u636e\u60a8\u7684\u7cfb\u7edf\u67e5\u627e\u76f8\u5e94\u7684\u5b89\u88c5\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>2. \u7f16\u8f91Nginx\u914d\u7f6e\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u7f16\u8f91Nginx\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u901a\u5e38\u4f4d\u4e8e `\/etc\/nginx\/nginx.conf`\u3002<\/p>\n<\/p>\n<p><pre><code>sudo nano \/etc\/nginx\/nginx.conf<\/code><\/pre>\n<\/p>\n<p><h3>3. \u6dfb\u52a0\u6d41\u91cf\u63a7\u5236\u914d\u7f6e<\/h3>\n<\/p>\n<p><p>\u5728Nginx\u7684server\u5757\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\u4ee5\u9650\u5236\u5ba2\u6237\u7aef\u8bf7\u6c42\u901f\u7387\uff1a<\/p>\n<\/p>\n<p><pre><code>http {<\/p>\r\n<p>    ...<\/p>\r\n<p>    server {<\/p>\r\n<p>        ...<\/p>\r\n<p>        location \/ {<\/p>\r\n<p>            limit_req_zone $binary_remote_addr zone=mylimit:10m rate=3r\/s;<\/p>\r\n\r\n<p>            limit_req zone=mylimit burst=10n;<\/p>\r\n\r\n<p>            ...<\/p>\r\n<p>        }<\/p>\r\n<p>    }<\/p>\r\n<p>}<\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc\u7684\u914d\u7f6e\u89e3\u91ca\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>limit_req_zone<\/strong>: \u8bbe\u7f6e\u8bf7\u6c42\u901f\u7387\u9650\u5236\u7684\u533a\u57df\u548c\u89c4\u5219\u3002`$binary_remote_addr` \u662f\u5ba2\u6237\u7aef\u7684IP\u5730\u5740\uff0c`zone` \u662f\u5185\u5b58\u4e2d\u7528\u4e8e\u5b58\u50a8\u9650\u5236\u6570\u636e\u7684\u533a\u57df\uff0c`10m` \u662f\u533a\u57df\u7684\u5927\u5c0f\uff0c`rate=3r\/s` \u662f\u6bcf\u79d2\u5141\u8bb8\u7684\u6700\u5927\u8bf7\u6c42\u6b21\u6570\u3002<\/li>\n<li><strong>limit_req<\/strong>: \u5e94\u7528\u9650\u5236\u89c4\u5219\u5230\u7279\u5b9a\u7684location\u3002`zone` \u53c2\u6570\u5f15\u7528\u4e0a\u9762\u5b9a\u4e49\u7684\u533a\u57df\uff0c`burst=10n` \u5141\u8bb8\u5728\u4e00\u5b9a\u65f6\u95f4\u5185\u8d85\u8fc7\u9650\u5236\u7684\u8bf7\u6c42\u6570\u91cf\u3002<\/li>\n<\/ul>\n<p><h3>4. \u4fdd\u5b58\u5e76\u91cd\u65b0\u52a0\u8f7dNginx\u914d\u7f6e<\/h3>\n<\/p>\n<p><p>\u4fdd\u5b58\u4fee\u6539\u540e\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u7136\u540e\u91cd\u65b0\u52a0\u8f7dNginx\u4ee5\u5e94\u7528\u66f4\u6539\uff1a<\/p>\n<\/p>\n<p><pre><code>sudo nginx -t<\/p>\r\n<p>sudo systemctl reload nginx<\/code><\/pre>\n<\/p>\n<p><h2>\u6ce8\u610f\u4e8b\u9879\u548c\u5b9e\u7528\u6280\u5de7<\/h2>\n<\/p>\n<p><h3>1. \u9047\u5230\u7684\u95ee\u9898<\/h3>\n<\/p>\n<ul>\n<li>\u5982\u679c\u60a8\u7684\u670d\u52a1\u5668\u6ca1\u6709\u8db3\u591f\u7684\u5185\u5b58\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u6027\u80fd\u95ee\u9898\u3002\u589e\u52a0\u5185\u5b58\u6216\u8c03\u6574`limit_req_zone`\u4e2d\u7684\u533a\u57df\u5927\u5c0f\u53ef\u4ee5\u89e3\u51b3\u3002<\/li>\n<li>\u5982\u679c\u5ba2\u6237\u7aef\u5728\u77ed\u65f6\u95f4\u5185\u53d1\u9001\u5927\u91cf\u8bf7\u6c42\uff0c\u53ef\u80fd\u4f1a\u8d85\u51fa\u5141\u8bb8\u7684\u7a81\u53d1\u8bf7\u6c42\u6570\u91cf\u3002\u9002\u5f53\u8c03\u6574`burst`\u53c2\u6570\u53ef\u4ee5\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\u3002<\/li>\n<\/ul>\n<p><h3>2. \u6ce8\u610f\u4e8b\u9879<\/h3>\n<\/p>\n<ul>\n<li>\u8bf7\u786e\u4fdd\u60a8\u7684\u670d\u52a1\u5668\u4e0a\u6ca1\u6709\u5176\u4ed6\u9650\u5236\u5ba2\u6237\u7aef\u8bf7\u6c42\u901f\u7387\u7684\u914d\u7f6e\uff0c\u4ee5\u907f\u514d\u51b2\u7a81\u3002<\/li>\n<li>\u5982\u679c\u60a8\u7684\u5e94\u7528\u9700\u8981\u66f4\u9ad8\u7684\u8bf7\u6c42\u901f\u7387\uff0c\u8bf7\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8c03\u6574`rate`\u548c`burst`\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5e94\u8be5\u5df2\u7ecf\u6210\u529f\u5730\u914d\u7f6e\u4e863Mbps\u7684\u5e26\u5bbd\u9650\u5236\u3002\u8fd9\u53ef\u4ee5\u5e2e\u52a9\u60a8\u7ba1\u7406\u670d\u52a1\u5668\u8d1f\u8f7d\uff0c\u63d0\u9ad8\u6027\u80fd\u548c\u53ef\u7528\u6027\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c06\u4e3a\u60a8\u8be6\u7ec6\u8bb2\u89e3\u5982\u4f55\u5728\u60a8\u7684\u670d\u52a1\u5668\u4e0a\u914d\u7f6e\u4e00\u4e2a3Mbps\u7684\u5e26\u5bbd\u9650\u5236\u3002\u8fd9\u5c06\u901a\u8fc7Nginx\u7684\u6d41\u91cf\u63a7\u5236\u6a21\u5757\u5b9e\u73b0\uff0c\u9002\u7528\u4e8e\u5e0c\u671b\u9650\u5236\u5ba2\u6237\u7aef\u8bf7\u6c42\u901f\u7387\u7684\u573a\u666f\u3002 \u64cd\u4f5c\u524d\u7684\u51c6\u5907 \u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u670d\u52a1\u5668\u5df2\u7ecf\u5b89\u88c5\u4e86Nginx\uff0c\u5e76\u4e14\u60a8\u6709\u76f8\u5e94\u7684\u6743\u9650\u6765\u4fee\u6539Nginx&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1316,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[192,299,289],"topic":[],"class_list":["post-1315","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hk-server","tag-mbps","tag-nginx","tag-289"],"_links":{"self":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/1315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/comments?post=1315"}],"version-history":[{"count":1,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/1315\/revisions"}],"predecessor-version":[{"id":1318,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/1315\/revisions\/1318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media\/1316"}],"wp:attachment":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media?parent=1315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/categories?post=1315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/tags?post=1315"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/topic?post=1315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}