Welcome! Log In Create A New Profile


Deny User Agents

Posted by nginx_user10 
Deny User Agents
March 10, 2017 11:51AM
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?

Edited 1 time(s). Last edit at 03/10/2017 12:00PM by nginx_user10.
Re: Deny User Agents
March 10, 2017 01:20PM

nginx for Windows http://nginx-win.ecsds.eu/
Re: Deny User Agents
March 10, 2017 01:30PM
Thanks for the link.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 65
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready