I'm trying to stop some pesky bots by blocking ther user agents in nginx. What is the best way to put multiple user-agents/matches in the same if statement when they have non-alphanumerical characters and need to be encaptulated with quotation marks.
This works:
if ($http_user_agent ~* (python|wget)) {
return 403;
}
if ($http_user_agent ~* "Opera/9.02 (Windows XP; U; ru)") {
return 403;
}
if ($http_user_agent ~* "Opera/9.70 (Linux i686 ; U; en) Presto/2.2.1") {
return 403;
}
But I'd rather something like this(which doesn't in this format):
if ($http_user_agent ~* (python|wget|"Opera/9.02 (Windows XP; U; ru)"|"Opera/9.70 (Linux i686 ; U; en) Presto/2.2.1") ) {
return 403;
}