nginx限流设置
nginx.conf设置########################worldapi############################## 这里取得原始用户的IP地址,没走CDN/SLB的,给到$remote_addrmap $http_x_forwarded_for$clientRealIp {default $remote_addr;~^(?P<firstAddr>[0-
·
nginx.conf设置
########################worldapi############################
## 这里取得原始用户的IP地址,没走CDN/SLB的,给到$remote_addr
map $http_x_forwarded_for $clientRealIp {
default $remote_addr;
~^(?P<firstAddr>[0-9.]+),?.*$ $firstAddr;
}
#设置IP白名单,对内部的IP不设限
map $clientRealIp $limit{
default $clientRealIp;
115.233.218.194 "";
115.198.223.22 "";
36.24.226.56 "";
#xx.xx.xx.xx "";
}
#以真实IP为单位,限制请求数,并返回429状态;
limit_req_status 429;
limit_req_zone $limit zone=ConnLimitZone:20m rate=80r/s;
limit_req_zone $limit zone=singleConnLimitZone:20m rate=5r/m;
limit_req_log_level notice;
#以真实IP为单位,限制该IP的并发连接数,并返回429状态;
limit_conn_status 429;
limit_conn_zone $limit zone=TotalConnLimitZone:20m ;
limit_conn TotalConnLimitZone 100;
limit_conn_log_level notice;
#以访问域名为单位,限制总并发链接数;
limit_conn_zone $server_name zone=SumConnLimitZone:20m;
########################worldapi############################
server.conf设置
location / {
#限制总并发连接数
#limit_conn SumConnLimitZone 10000;
#最多5个排队, 由于每秒处理 50 个请求 + 5个排队,你一秒最多发送 55 个请求过来,再多就直接返回 429 错误给你了
limit_req zone=ConnLimitZone burst=5 nodelay;
proxy_pass http://xxxxi;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Cache-Control no-cache;
add_header Cache-Control private;
}

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。
更多推荐
所有评论(0)