I have many domain names folder in /etc/letsencrypt/live/ this location with cert pem and cert key file. I want to serve any type of domain SSL key that in my /etc/letsencrypt/live/ directory and I programmatically add different domain in this directory.
my nginx.conf file
server {
listen 443 ssl;
server_name default_server;
map "$host" $domain_name { ~(.*)\.(.*)\.(.*)$ $2.$3; }
ssl_certificate /etc/letsencrypt/live/$domain_name/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/$domain_name/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
client_max_body_size 20M;
...
}
But when I request a domain I got the error. No such file or directory:fopen('/etc/letsencrypt/live/default_server/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file) while SSL handshaking
So $domain_name variable not transletting correctly it turns into default_server . How can I achieve this type of things. Thank you!.