I am new to ngnix, new as in I have never heard of it until 2 weeks ago.
I am trying to deny certain user agents access.
I have following code in the sites-available/default file.
set $block_user_agents 0;
if ($http_user_agent ~ "Wget") {
set $block_user_agents 1;
}
if ($block_user_agents = 1) {
return 404;
}
When I try to reload nginx it fails. when I comment out the code it works. My question is how do you block user agents and is my code in the correct file?
Thanks for any help.
I have found the answer.
if ($http_user_agent ~* (Wget) ) {
return 403;
}
Where is the link that shows you how to write if statements in nginx?
I am trying to deny certain user agents access.
I have following code in the sites-available/default file.
set $block_user_agents 0;
if ($http_user_agent ~ "Wget") {
set $block_user_agents 1;
}
if ($block_user_agents = 1) {
return 404;
}
When I try to reload nginx it fails. when I comment out the code it works. My question is how do you block user agents and is my code in the correct file?
Thanks for any help.
I have found the answer.
if ($http_user_agent ~* (Wget) ) {
return 403;
}
Where is the link that shows you how to write if statements in nginx?