{"id":1214,"date":"2023-04-04T14:04:28","date_gmt":"2023-04-04T06:04:28","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=1214"},"modified":"2023-04-07T09:52:13","modified_gmt":"2023-04-07T01:52:13","slug":"speed-limit-configuration-for-ingress-nginx-in-kubernetes","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2023\/04\/speed-limit-configuration-for-ingress-nginx-in-kubernetes\/","title":{"rendered":"\u5728 kubernetes\u4e2d ingress-nginx \u9650\u901f\u914d\u7f6e"},"content":{"rendered":"
\u5728Kubernetes\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u6ce8\u91ca\u6765\u5b9a\u4e49\u8fde\u63a5\u548c\u4f20\u8f93\u901f\u7387\u7684\u9650\u5236\uff0c\u4ee5\u4fbf\u51cf\u8f7bDDoS\u653b\u51fb\u3002<\/p>\n
\u9996\u5148\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u201cnginx.ingress.kubernetes.io\/limit-connections\u201d\u6ce8\u91ca\u6765\u5b9a\u4e49\u5355\u4e2aIP\u5730\u5740\u5141\u8bb8\u7684\u5e76\u53d1\u8fde\u63a5\u6570\u3002\u5f53\u8d85\u8fc7\u6b64\u9650\u5236\u65f6\uff0c\u5c06\u8fd4\u56de503\u9519\u8bef\u3002<\/p>\n
\u5176\u6b21\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u201cnginx.ingress.kubernetes.io\/limit-rps\u201d\u6ce8\u91ca\u6765\u9650\u5236\u6bcf\u79d2\u63a5\u53d7\u6765\u81ea\u7ed9\u5b9aIP\u7684\u8bf7\u6c42\u6570\u91cf\u3002\u7206\u53d1\u9650\u5236\u8bbe\u7f6e\u4e3a\u8be5\u9650\u5236\u4e58\u4ee5\u7206\u53d1\u4e58\u6570\uff0c\u8be5\u9ed8\u8ba4\u4e58\u6570\u4e3a5\u3002\u5f53\u5ba2\u6237\u7aef\u8d85\u8fc7\u6b64\u9650\u5236\u65f6\uff0c\u5c06\u8fd4\u56de\u201climit-req-status-code\u201d\u9ed8\u8ba4\u503c\uff1a503\u3002<\/p>\n
\u540c\u6837\u5730\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u201cnginx.ingress.kubernetes.io\/limit-rpm\u201d\u6ce8\u91ca\u6765\u9650\u5236\u6bcf\u5206\u949f\u63a5\u53d7\u6765\u81ea\u7ed9\u5b9aIP\u7684\u8bf7\u6c42\u6570\u91cf\u3002\u7206\u53d1\u9650\u5236\u8bbe\u7f6e\u4e3a\u8be5\u9650\u5236\u4e58\u4ee5\u7206\u53d1\u4e58\u6570\uff0c\u8be5\u9ed8\u8ba4\u4e58\u6570\u4e3a5\u3002\u5f53\u5ba2\u6237\u7aef\u8d85\u8fc7\u6b64\u9650\u5236\u65f6\uff0c\u5c06\u8fd4\u56de\u201climit-req-status-code\u201d\u9ed8\u8ba4\u503c\uff1a503\u3002<\/p>\n
\u8fd8\u6709\u4e00\u4e2a\u6ce8\u91ca\u201cnginx.ingress.kubernetes.io\/limit-burst-multiplier\u201d\uff0c\u5b83\u662f\u9650\u5236\u901f\u7387\u7684\u7206\u53d1\u5927\u5c0f\u7684\u9650\u5236\u901f\u7387\u7684\u4e58\u6570\u3002\u9ed8\u8ba4\u7206\u53d1\u4e58\u6570\u4e3a5\uff0c\u8fd9\u4e2a\u6ce8\u91ca\u53ef\u4ee5\u8986\u76d6\u9ed8\u8ba4\u503c\u3002\u5f53\u5ba2\u6237\u7aef\u8d85\u8fc7\u6b64\u9650\u5236\u65f6\uff0c\u5c06\u8fd4\u56de\u201climit-req-status-code\u201d\u9ed8\u8ba4\u503c\uff1a503\u3002<\/p>\n
\u6b64\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u201cnginx.ingress.kubernetes.io\/limit-rate-after\u201d\u6ce8\u91ca\u6765\u5b9a\u4e49\u4f20\u8f93\u7ed9\u5355\u4e2a\u8fde\u63a5\u7684\u54cd\u5e94\u5728\u521d\u59cb\u7684\u591a\u5c11\u5343\u5b57\u8282\u4e4b\u540e\u5f00\u59cb\u9650\u901f\u3002\u8981\u4f7f\u7528\u6b64\u529f\u80fd\uff0c\u5fc5\u987b\u542f\u7528\u4ee3\u7406\u7f13\u51b2\u3002<\/p>\n
\u6700\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u201cnginx.ingress.kubernetes.io\/limit-rate\u201d\u6ce8\u91ca\u6765\u5b9a\u4e49\u6bcf\u79d2\u949f\u5141\u8bb8\u53d1\u9001\u7ed9\u5355\u4e2a\u8fde\u63a5\u7684\u5343\u5b57\u8282\u6570\u3002\u5982\u679c\u5c06\u6b64\u503c\u8bbe\u7f6e\u4e3a\u96f6\uff0c\u5219\u8868\u793a\u7981\u7528\u901f\u7387\u9650\u5236\u3002\u8981\u4f7f\u7528\u6b64\u529f\u80fd\uff0c\u5fc5\u987b\u542f\u7528\u4ee3\u7406\u7f13\u51b2\u3002<\/p>\n
\u9664\u6b64\u4e4b\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u4f7f\u7528\u201cnginx.ingress.kubernetes.io\/limit-whitelist\u201d\u6ce8\u91ca\u6765\u5b9a\u4e49\u4e0d\u53d7\u901f\u7387\u9650\u5236\u7684\u5ba2\u6237\u7aefIP\u6e90\u8303\u56f4\u3002\u8be5\u503c\u662f\u4e00\u4e2a\u9017\u53f7\u5206\u9694\u7684CIDR\u5217\u8868\u3002<\/p>\n
\u5982\u679c\u5728\u4e00\u4e2aIngress\u89c4\u5219\u4e2d\u6307\u5b9a\u591a\u4e2a\u6ce8\u91ca\uff0c\u5219\u9650\u5236\u5c06\u6309\u7167\u201climit-connections\u201d\u3001\u201climit-rpm\u201d\u3001\u201climit-rps\u201d\u7684\u987a\u5e8f\u5e94\u7528\u3002<\/p>\n
\u8981\u5728\u6240\u6709Ingress\u89c4\u5219\u4e2d\u5168\u5c40\u914d\u7f6e\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u5728NGINX ConfigMap\u4e2d\u8bbe\u7f6e\u201climit-rate-after\u201d\u548c\u201climit-rate\u201d\u503c\u3002\u5728Ingress\u6ce8\u91ca\u4e2d\u8bbe\u7f6e\u7684\u503c\u5c06\u8986\u76d6\u5168\u5c40\u8bbe\u7f6e\u3002<\/p>\n
\u5ba2\u6237\u7aefIP\u5730\u5740\u5c06\u57fa\u4e8e\u4f7f\u7528PROXY\u534f\u8bae\u6216\u542f\u7528\u201cuse-forwarded-headers\u201d\u65f6\u4eceX-Forwarded-For\u5934\u503c\u8bbe\u7f6e\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5728Kubernetes\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u6ce8\u91ca\u6765\u5b9a\u4e49\u8fde\u63a5\u548c\u4f20\u8f93\u901f\u7387\u7684\u9650\u5236\uff0c\u4ee5\u4fbf\u51cf\u8f7bDDoS\u653b\u51fb\u3002 \u9996\u5148\uff0c\u6211\u4eec\u53ef<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[34],"tags":[],"yoast_head":"\n