In my little virtual-hosts config with nginx I encountered a new problem.
I tried to setup a "webmail
" subdomain for every one of my virtual hosts using a server_name
wildcard
server_name ~^(webmail\.)?(?<domain>.+)$;
as all my domains have their own ssl-certificate I would like to use the right one for the webmail-subdomains too. The certificates are configured as wildcard-certs as in *.domain1.com
etc.
So webmail.domain1.com
should use the cert for *.domain1.com
whereas webmail.domain2.net
should use the *.domain2.net
cert.
I tried the following as a first guess but could not start nginx because it does not accept the variable in the path:
ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem;
Is there a way to achieve this configuration with a single config-file covering all webmail.*
subdomains?