The best way How to protect bot request on production server?

On the production server have often bot request. i want to know how to protect or block these request ?. or the best way to i do ?

This isn’t a Django issue - you may find more / better resources elsewhere.

You would generally resolve this at either the web server (e.g. nginx), proxy (e.g. haproxy), or firewall (e.g fail2ban) layer. You should not be allowing these requests to make it through to Django.

You’re not going to stop this, the best you can do is filter it as early in the stack as possible.

To mitigate this, what I did was to add this block in my nginx server to ensure that requests that are not defined in this my app routes or its base do not hit my django app. You can get all base routes / apps from your project and list them here, as seen in the sample below

map $request_uri $allowed_uri {
    default 0;
    ~^/$ 1;
    ~^/transactions 1;
    ~^/wallets/ 1;
}

then specify inside my https server block to implement the logic;

    location / {
#       include /etc/nginx/conf.d/allowed_urls.conf
        if ($http_user_agent ~* (sqlmap|scrapy|curl) ) { # this to block weird user agents
            return 403;
        }
        if ($allowed_uri = 0) {
            return 403;
        }
      # the remaining part of your proxy settings