Nginx common IP whitelist for all subdomains

If I have a number of virtual hosts in the sites-enabled folder, how can I have a common whitelist for all of them?

Aka each one has this block

    allow 127.0.0.1;
    allow 192.168.0.0/16;
    allow x.x.x.x;
    deny all;

How can I have that apply to all the virtual hosts by default, instead of having to write it for every subdomain?


Use include

eg put the following text in the file /etc/nginx/shared-configs/whitelist.conf

allow 127.0.0.1;
allow 192.168.0.0/16;
allow x.x.x.x;
deny all;

in the file /etc/nginx/sites-enabled/site1.conf

server {
  server_name example.com;
  include /etc/nginx/shared-configs/whitelist.conf;
}

in the file /etc/nginx/sites-enabled/site2.conf

server {
  server_name site2.example.com;
  include /etc/nginx/shared-configs/whitelist.conf;
}