1

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?

Julien
  • 242
  • 1
  • 3
  • 13
  • https://serverfault.com/a/707963/8710 You can move some settings to a separate file and then include in the right locations. – Lex Li Dec 24 '22 at 03:30
  • @LexLi i would still need to edit the hundreds of files for each the sites – Julien Dec 24 '22 at 18:09

0 Answers0