You should look into Trellis it allows you to configure multi-sites and multi-tenanted WordPress sites and it configures the Nginx for you using a simple config file. The only catch is its subdomain based and you'll need to tinker around a bit with the generated config.
Here's my suggestion
Nginx support multiple location within server{} blocks configuration which could be what you're looking for.
# This block redirects all request from HTTP to HTTPS without losing any arguments or parameters
server {
listen 80;
server_name site.com;
# root /var/www/html;
return 301 https://$server_name$request_uri;
location / {
return 301 https://$server_name$request_uri;
}
}
server {
listen 443 ssl;
server_name site.com;
location /demos/theme1/ {
root /var/www/html/demos/theme1;
client_max_body_size 100M;
}
location /demos/theme2/ {
root /var/www/html/demos/theme2;
client_max_body_size 100M;
}
# listen 443 ssl; # managed by Certbot
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
ssl_session_cache shared:le_nginx_SSL:1m;
ssl_session_timeout 1440m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-ECDSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES256-GCM-SHA384 ECDHE-ECDSA-AES128-SHA ECDHE-ECDSA-AES256-SHA ECDHE-ECDSA-AES128-SHA256 ECDHE-ECDSA-AES256-SHA384 ECDHE-RSA-AES128-GCM-SHA256 ECDHE-RSA-AES256-GCM-SHA384 ECDHE-RSA-AES128-SHA ECDHE-RSA-AES128-SHA256 ECDHE-RSA-AES256-SHA384 DHE-RSA-AES128-GCM-SHA256 DHE-RSA-AES256-GCM-SHA384 DHE-RSA-AES128-SHA DHE-RSA-AES256-SHA DHE-RSA-AES128-SHA256 DHE-RSA-AES256-SHA256 EDH-RSA-DES-CBC3-SHA";
}
Then save this into a file with .conf extension (/etc/nginx/sites-available/site.conf) in the /etc/nginx/sites-availabe/ and create a symbolic link to that file in /etc/nginx/sites-enabled/ folder as Nginx recommended. But you can place the file directly in the /etc/nginx/sites-enabled/ folder and forget symbolic links.
You should use one file per domains (multi-site) so its easier to bugfix as one bugged config file may takedown the Nginx with 500 - Internal server error or 502 - Bad Gateway
This is a workaround for your scenario but it's really messy, so source control is recommended.
If the multi-sites has their own domains you should configure each multi-site in their own config file.