Difference between revisions of "Block particular user agent (bots) in nginx"
From DevOps Notebook
Line 2: | Line 2: | ||
<syntaxhighlight lang="nginx"> | <syntaxhighlight lang="nginx"> | ||
# case insensitive matching | # case insensitive matching | ||
− | if ($http_user_agent ~* ( | + | if ($http_user_agent ~* (crawler1|spiderbot|wget|curl)) { |
return 403; | return 403; | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Latest revision as of 18:57, 8 October 2020
Add inside nginx server block
# case insensitive matching
if ($http_user_agent ~* (crawler1|spiderbot|wget|curl)) {
return 403;
}