Nginx Reverse Proxy Multi-file configuration

rg305,

Let's see if I can explain better what I want to achieve. Like portainer, I had a file for pihole the same way as the portainer one (just replacing portainer for pihole and different ip addresses). To make it use the SSL certificate (HTTPS) I modified the file to mimic the final version of the plain eddienetworks.ddnsfree.com. The resulting file is:

server {
         listen 80;
         server_name pihole.eddienetworks.ddnsfree.com *.pihole.eddienetworks.ddnsfree.com;
         return 301 https://$host$request_uri;
}

server {
        listen [::]:443 ssl; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/eddienetworks.ddnsfree.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/eddienetworks.ddnsfree.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

        server_name pihole.eddienetworks.ddnsfree.com *.pihole.eddienetworks.ddnsfree.com;

        location / {
                proxy_pass http://192.168.1.240;
                proxy_set_header Host $host;
        }
}

And then the website loads encrypted. My question is if there's a way to do this to every file (or the ones I choose) automatically or only manually. Also, a matter of information, any variation of the website that is not included in one the proxy files such as:

www.eddienetworks.ddnsfree.com
test.eddienetworks.ddnsfree.com

are working fine (redirecting HTTP to HTTPS).

Thanks