Table of Contents

, ,

Expand existing letsencrypt certficate for multiple domains

Check existing certifcates

certbot-auto certificates

Expand existing one

Remember to include the already existing domain certificate (staging.example.com).

certbot-auto certonly --expand -d staging.example.com,subdomain1.staging.example.com,subdomain100.staging.example.com,subdomain200.staging.example.com

This will result in a certificate valid for all above domains.

Tweak the apache configuration

Only additions are shown below.

Non ssl conf:

...
ServerAlias *.staging.example.com
...
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

SSL conf:

...
ServerAlias *.staging.example.com
...
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/staging.example.com-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/staging.example.com-0001/privkey.pem

Tested on

See also