![NGINX `limit_req` がインデックス ファイルの場所ディレクティブで機能しない](https://rvso.com/image/170644/NGINX%20%60limit_req%60%20%E3%81%8C%E3%82%A4%E3%83%B3%E3%83%87%E3%83%83%E3%82%AF%E3%82%B9%20%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E5%A0%B4%E6%89%80%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%86%E3%82%A3%E3%83%96%E3%81%A7%E6%A9%9F%E8%83%BD%E3%81%97%E3%81%AA%E3%81%84.png)
に nginx location ディレクティブを追加しようとしていますlimit_req
が、うまくいきません。
を追加したいターゲットが 2 つありますlimit_req
。
ウェブサイト API パス ここに私のサーバー構成ファイルがあります。
server {
server_name example.com; # managed by Certbot
root /var/www/;
index index.php index.html index.htm;
location / {
root /var/www/;
index index.php;
try_files $uri $uri/ /index.php?$args;
}
location /example.com/{
limit_req zone=mylimit;
root /var/www/example.com/;
index index.php?$args;
try_files $uri $uri/ /example.com/index.php?$args;
}
location /example.com/api/ {
limit_req zone=mylimit burst=20 nodelay;
root /var/www/example.com/api/;
index index.php?$args;
try_files $uri $uri/ /example.com/api/index.php?$args;
}
}
上記の設定を、Web サイトのログイン URL を並列で実行してテストすると、limit_req は機能します。ただし、同じテストを API に対して実行すると、機能しません。
すべての API がhttps://example.com/api/index.php
URL にヒットします。誰か助けてくれませんか?
私はテスト目的で seige を使用しています。
siege -b -r 1 -c 10 https://example.com/api/index.php
誰か助けてくれませんか?
前もって感謝します。