Take a look at this: http://ask.xmodulo.com/block-specific-user-agents-nginx-web-server.html
Personally, I would use the map feature since eventually there will be other user agents to block. I use three maps. I block based on requests, referrals, and user agents. The user agent is kind of obvious. Unwanted referrals is a personal thing. I find some websites linking to me that are pure crap like stumbleupon. I don't want their traffic. Yeah sometimes stumbleupon has a relevant link, but most of the time their links make no sense. Some sites will link to your website for SEO. Some linking is just freakin out there, like when Hamas linked to my site. (Humus I like...Hamas not so much. ) Blocking requests is useful if you want to get the IPs of hackers. I find many requests for the directory "backup." I even have the Chinese equivalent to backup in my bad request trap. Rather than let them 404, I 444 them, and then check the IP to see if it goes to a hosting company, VPS, VPN, etc. You can't block enough IPs at the firewall in my opinion. Every IP you block that isn't an eyeball, even if harmless today, might be harmful in the future. No eyeballs, no need to view the site. Original Message From: xstation Sent: Thursday, December 15, 2016 10:35 PM To: [email protected] Reply To: [email protected] Subject: Re: nginx.conf If I delete the if! I get an error root@mail:~# nginx -t -c /etc/nginx/nginx.conf nginx: [emerg] unknown directive "($http_user_agent" in /etc/nginx/nginx.conf:82 nginx: configuration file /etc/nginx/nginx.conf test failed Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271585#msg-271585 _______________________________________________ nginx mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx _______________________________________________ nginx mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx
