We have hundreds of sites running on an Nginx server, each one has it's own config file in site-available
/ enabled
that contains their server blocks and are loaded by the nginx.conf
in the http
block by doing include /etc/nginx/sites-enabled/*;
.
Now i would like to block access to the sites for specific user agents (pesky bots), i was wondering if could apply something like:
if ($http_user_agent ~* "bot1|bot1|bot3") { return 444; }
to all sites without having to edit every individual site config files.
Could i add it in the http
block, would that affect all server blocks included?
Is there a better way that won't have me code a script to update the hundreds of sites' config files?