Difference between revisions of "Block particular user agent (bots) in nginx"
From DevOps Notebook
(Created page with "<pre> # case insensitive matching if ($http_user_agent ~* (netcrawl|npbot|malicious|LWP::Simple|BBBike|wget|jorgee)) { return 403; } </pre>") |
|||
Line 1: | Line 1: | ||
− | < | + | Add inside nginx server block |
+ | <syntaxhighlight lang="nginx"> | ||
# case insensitive matching | # case insensitive matching | ||
if ($http_user_agent ~* (netcrawl|npbot|malicious|LWP::Simple|BBBike|wget|jorgee)) { | if ($http_user_agent ~* (netcrawl|npbot|malicious|LWP::Simple|BBBike|wget|jorgee)) { | ||
return 403; | return 403; | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
Revision as of 18:56, 8 October 2020
Add inside nginx server block
# case insensitive matching
if ($http_user_agent ~* (netcrawl|npbot|malicious|LWP::Simple|BBBike|wget|jorgee)) {
return 403;
}