
在本地测试静态 html 文件的时候问没有问题。
静态 html 时 nginx 配置
在 http 块
limit_req_zone $binary_remote_addr zOne=req_zone:1m rate=1r/m; 1 分钟限制访问 1 次
在 server 块
location /test.html { root /home/admin/www; limit_req zOne=req_zone; } python 使用 requests 压测,除了第一次返回 200 ,其余都是 503 。
而在 wordpress 的 nginx 里面: http 块不变,
server 块如下:
location ~ \.php$ { root /var/www/html; fastcgi_pass php-mysql:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ \wp-login.php$ { limit_req zOne=req_zone; } 同样的压测代码,发现限制不起作用。 请教下运维的高手同学,哪里出问题了。
1 alvinbone88 2022-04-21 20:04:29 +08:00 location 顺序问题,下面的那个不会被匹配到 以及,匹配 wp-login 的那个正则有问题,能匹配到也只是碰巧 |
2 yagamil OP |
3 alvinbone88 2022-04-22 10:41:31 +08:00 还要在匹配 wp-login 的配置里加上 fastcgi_pass |
4 yagamil OP @alvinbone88 谢谢,我去试试 |