这是我的 nginx 配置:
{
# on top of conf file
limit_req_zone $binary_remote_addr zone=main:10m rate=1r/s;
...
location /login {
limit_req zone=main burst=3 nodelay;
ModSecurityEnabled on;
ModSecurityConfig /usr/local/nginx/conf/modsecurity.conf;
proxy_pass http://localhost:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Run Code Online (Sandbox Code Playgroud)
使用以下代码多次点击 api url (http://localhost:4000/login) 时 -
for i in {0..2000}; do (curl -Is http://localhost:4000/login | head -n1 &) 2>/dev/null; done
Run Code Online (Sandbox Code Playgroud)
对于一些应该被拒绝的请求,我总是得到 200 响应代码而不是 503。为什么会这样?