Block particular user agent (bots) in nginx

From DevOps Notebook
Revision as of 18:57, 8 October 2020 by MilosZ (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Add inside nginx server block

    # case insensitive matching
    if ($http_user_agent ~* (crawler1|spiderbot|wget|curl)) {
        return 403;
    }