Score:1

Apply same config to all server blocks

cn flag

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?

Lex Li avatar
vn flag
https://serverfault.com/a/707963/8710 You can move some settings to a separate file and then include in the right locations.
Julien avatar
cn flag
@LexLi i would still need to edit the hundreds of files for each the sites
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.