You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Nginx 1.18服务器压测遇429错误,关闭limit_rate仍未解决

Nginx禁用速率限制后仍出现429 Too Many Requests错误

问题详情

服务器配置:2vCPU、7GB内存,运行Nginx 1.18版本
负载测试场景:每秒约300次HTTP请求
现象:测试开始几秒后返回429错误,已通过limit_rate 0禁用Nginx速率限制,问题未解决。

当前Nginx Server配置

server {
    listen 80;
    listen [::]:80;
    server_name _;
    root /var/www/laravel-rsync/public;
 
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-Content-Type-Options "nosniff";
 
    index index.php;
 
    charset utf-8;
    
    limit_rate 0;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
 
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
 
    error_page 404 /index.php;
 
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
 
    location ~ /\.(?!well-known).* {
        deny all;
    }
}

解决方法

问题出在应用层而非Nginx:Laravel默认对所有/api路由启用了节流(throttle)中间件,这是触发429错误的真正原因。

只需修改Laravel的路由配置即可解决:

  1. 打开路由文件routes/api.php
  2. 找到包含throttle中间件的路由组配置,注释掉该中间件即可。

内容的提问来源于stack exchange,提问作者user17179924

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 16:27:05