不要なボットがサーバー上のサイトにアクセスしないようにしたい。不要な接続を削除する
nginxは特定のBotが検出されたときすぐに接続を切断/強制終了できますか?
if ($http_user_agent ~ (agent1|agent2)) {
**KILL CONNECTION**;
}
上記の例のようなものです。
不要なボットがサーバー上のサイトにアクセスしないようにしたい。不要な接続を削除する
nginxは特定のBotが検出されたときすぐに接続を切断/強制終了できますか?
if ($http_user_agent ~ (agent1|agent2)) {
**KILL CONNECTION**;
}
上記の例のようなものです。
return 444; This non-standard status code of 444 causes nginx to simply close the connection without responding to it。
if ($http_user_agent ~ (agent1|agent2)) {
return 444;
}
はい、できます。以下の質問を参照してください。これはエージェント文字列に基づいてリダイレクトされますが、実際には何でもできます(エラーページなど)。
Nginx proxy or rewrite depending on user agent
しかし、注意してください - まともなボットは、そのユーザーエージェント文字列偽となるように、これは決してあなたのサイトを掃引からボットを阻止するための確実な方法である、ちょうど通常のブラウザのように見えます。
この質問は、あなたが全く話していない接続を削除することについてです。質問のサンプルコードはすでにユーザーエージェントの決定を処理しているので、それは不明瞭ではありません。 – Kissaki
server {
listen 8443 default ssl;
error_page 404 403 = 444; #disconnect if 404 or 403
root /srv/empty; #Empty forder
...
...
location /summary_report{
root /srv/www;
index index.html index.htm;
}
}
https://127.0.0.1/ 切断。
https://127.0.0.1/summary_report 切断しないでください。
これは/ 444をリダイレクトループで処理しようとします。 – user193661
nginx [documentation about 444](http://nginx.org/en/docs/http/request_processing.html#how_to_prevent_undefined_server_names) – befzz