B
B
Bermut2021-11-20 08:44:01
Nginx
Bermut, 2021-11-20 08:44:01

How to block all bots?

You need to configure Nginx to block any clients that write to the user-agent that they are bots (for example, search engines, social networks, and so on).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Karabanov, 2021-11-20
@Bermut

Add a map to the http section, something like:

map $http_user_agent $isbot {
        default 0;
        ~*Googlebot 1;
        ~*bingbot 1;
        # и так далее
}

And in the server section:
if ($isbot) {
        return 403;
}

PS
Uncovering the possibilities of map in nginx
About using regexp in map nginx

K
ky0, 2021-11-20
@ky0

Easily searched on stackoverflow. It works, of course, only for those who present themselves honestly - and there are usually no problems from such people. What problem are you solving?

T
TheAndrey7, 2021-11-20
@TheAndrey7

Normal robots follow the rules specified in robots.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question