Failed Challenge on ZoneMinder [Apache]

/etc/apache2/sites-enabled$ cat zm.conf
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName www.biggszm.duckdns.org
        ServerAlias biggszm.duckdns.org

        ServerAdmin webmaster@localhost
        DocumentRoot /usr/share/zoneminder/www

        # Remember to enable cgi mod (i.e. "a2enmod cgi").
        ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
        <Directory "/usr/lib/zoneminder/cgi-bin">
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            AllowOverride All
            Require all granted
        </Directory>


        # Order matters. This alias must come first.
        Alias /zm/cache /var/cache/zoneminder/cache
        <Directory /var/cache/zoneminder/cache>
            Options -Indexes +FollowSymLinks
            AllowOverride None
            <IfModule mod_authz_core.c>
                # Apache 2.4
                Require all granted
            </IfModule>
        </Directory>

        Alias /zm /usr/share/zoneminder/www
        <Directory /usr/share/zoneminder/www>
            Options -Indexes +FollowSymLinks
            <IfModule mod_dir.c>
                DirectoryIndex index.php
            </IfModule>
        </Directory>

        # For better visibility, the following directives have been migrated from the
        # default .htaccess files included with the CakePHP project.
        # Parameters not set here are inherited from the parent directive above.
        <Directory "/usr/share/zoneminder/www/api">
            RewriteEngine on
            RewriteRule ^$ app/webroot/ [L]
            RewriteRule (.*) app/webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app">
            RewriteEngine on
            RewriteRule ^$ webroot/ [L]
            RewriteRule (.*) webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app/webroot">
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
            RewriteBase /zm/api
        </Directory>


        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
RewriteCond %{SERVER_NAME} =biggszm.duckdns.org [OR]
RewriteCond %{SERVER_NAME} =www.biggszm.duckdns.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
apachectl -S
AH00526: Syntax error on line 88 of /etc/apache2/sites-enabled/zm-le-ssl.conf:
SSLCertificateFile: file '/etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem' does not exist or is empty
Action '-S' failed.
The Apache error log may have more information.
1 Like

Please show this file:

and also the output of:
certbot certificates

1 Like
/etc/apache2/sites-enabled$ cat zm-le-ssl.conf 
<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName www.biggszm.duckdns.org
        ServerAlias biggszm.duckdns.org

        ServerAdmin webmaster@localhost
        DocumentRoot /usr/share/zoneminder/www

        # Remember to enable cgi mod (i.e. "a2enmod cgi").
        ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
        <Directory "/usr/lib/zoneminder/cgi-bin">
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            AllowOverride All
            Require all granted
        </Directory>


        # Order matters. This alias must come first.
        Alias /zm/cache /var/cache/zoneminder/cache
        <Directory /var/cache/zoneminder/cache>
            Options -Indexes +FollowSymLinks
            AllowOverride None
            <IfModule mod_authz_core.c>
                # Apache 2.4
                Require all granted
            </IfModule>
        </Directory>

        Alias /zm /usr/share/zoneminder/www
        <Directory /usr/share/zoneminder/www>
            Options -Indexes +FollowSymLinks
            <IfModule mod_dir.c>
                DirectoryIndex index.php
            </IfModule>
        </Directory>

        # For better visibility, the following directives have been migrated from the
        # default .htaccess files included with the CakePHP project.
        # Parameters not set here are inherited from the parent directive above.
        <Directory "/usr/share/zoneminder/www/api">
            RewriteEngine on
            RewriteRule ^$ app/webroot/ [L]
            RewriteRule (.*) app/webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app">
            RewriteEngine on
            RewriteRule ^$ webroot/ [L]
            RewriteRule (.*) webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app/webroot">
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
            RewriteBase /zm/api
        </Directory>


        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/biggszm.duckdns.org/privkey.pem
</VirtualHost>
</IfModule>

sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: biggszm.duckdns.org
    Serial Number: 3ffb3d213dab9964367d72ccf063f9b79b3
    Key Type: RSA
    Domains: biggszm.duckdns.org
    Expiry Date: 2021-10-13 20:48:08+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/biggszm.duckdns.org/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 Like

hmm...

Apache is complaining about these files not existing:

SSLCertificateFile /etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/biggszm.duckdns.org/privkey.pem

Meanwhile, certbot says they do:

Sooooo....
What are we missing ? ? ?

Please show:
ls -l /etc/letsencrypt/live/biggszm.duckdns.org/

1 Like

Well...


This:

needs to be this:

sudo apachectl -S

to determine if this happened correctly:


If this did actually happen:

I can't see any evidence of it here:

or here:


Possibly many things at this point.

We would need the complete outputs of these to know for sure:

sudo certbot certificates
sudo ls -lRa /etc/letsencrypt
sudo apachectl -S
sudo ls -lRa /etc/apache2/sites-available
sudo ls -lRa /etc/apache2/sites-enabled

Please put 3 backticks above and below each output, like this:

```
output
```

1 Like
sudo apachectl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443                  www.biggszm.duckdns.org (/etc/apache2/sites-enabled/zm-le-ssl.conf:2)
*:80                   www.biggszm.duckdns.org (/etc/apache2/sites-enabled/zm.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33
sudo ls -l /etc/letsencrypt/live/biggszm.duckdns.org/
total 4
lrwxrwxrwx 1 root root  43 Jul 15 16:48 cert.pem -> ../../archive/biggszm.duckdns.org/cert1.pem
lrwxrwxrwx 1 root root  44 Jul 15 16:48 chain.pem -> ../../archive/biggszm.duckdns.org/chain1.pem
lrwxrwxrwx 1 root root  48 Jul 15 16:48 fullchain.pem -> ../../archive/biggszm.duckdns.org/fullchain1.pem
lrwxrwxrwx 1 root root  46 Jul 15 16:48 privkey.pem -> ../../archive/biggszm.duckdns.org/privkey1.pem
-rw-r--r-- 1 root root 692 Jul 15 16:48 README
sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: biggszm.duckdns.org
    Serial Number: 3ffb3d213dab9964367d72ccf063f9b79b3
    Key Type: RSA
    Domains: biggszm.duckdns.org
    Expiry Date: 2021-10-13 20:48:08+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/biggszm.duckdns.org/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sudo ls -lRa /etc/letsencrypt
/etc/letsencrypt:
total 56
drwxr-xr-x   9 root root  4096 Jul 15 21:49 .
drwxr-xr-x 136 root root 12288 Jul 15 16:53 ..
drwx------   4 root root  4096 Jul 14 13:25 accounts
drwx------   3 root root  4096 Jul 15 16:48 archive
-rw-r--r--   1 root root   121 Feb 11  2019 cli.ini
drwxr-xr-x   2 root root  4096 Jul 15 16:48 csr
drwx------   2 root root  4096 Jul 15 16:48 keys
drwx------   3 root root  4096 Jul 15 16:48 live
-rw-r--r--   1 root root   952 Jul 15 16:57 options-ssl-apache.conf
drwxr-xr-x   2 root root  4096 Jul 15 16:48 renewal
drwxr-xr-x   5 root root  4096 Jul 14 10:22 renewal-hooks
-rw-r--r--   1 root root    64 Jul 15 16:57 .updated-options-ssl-apache-conf-digest.txt

/etc/letsencrypt/accounts:
total 16
drwx------ 4 root root 4096 Jul 14 13:25 .
drwxr-xr-x 9 root root 4096 Jul 15 21:49 ..
drwx------ 3 root root 4096 Jul 14 13:25 acme-staging-v02.api.letsencrypt.org
drwx------ 3 root root 4096 Jul 14 10:22 acme-v02.api.letsencrypt.org

/etc/letsencrypt/accounts/acme-staging-v02.api.letsencrypt.org:
total 12
drwx------ 3 root root 4096 Jul 14 13:25 .
drwx------ 4 root root 4096 Jul 14 13:25 ..
drwx------ 3 root root 4096 Jul 14 13:25 directory

/etc/letsencrypt/accounts/acme-staging-v02.api.letsencrypt.org/directory:
total 12
drwx------ 3 root root 4096 Jul 14 13:25 .
drwx------ 3 root root 4096 Jul 14 13:25 ..
drwx------ 2 root root 4096 Jul 14 13:25 ee8fc3e4c15322f645c89cda0dd6e9b6

/etc/letsencrypt/accounts/acme-staging-v02.api.letsencrypt.org/directory/ee8fc3e4c15322f645c89cda0dd6e9b6:
total 20
drwx------ 2 root root 4096 Jul 14 13:25 .
drwx------ 3 root root 4096 Jul 14 13:25 ..
-rw-r--r-- 1 root root   80 Jul 14 13:25 meta.json
-r-------- 1 root root 1630 Jul 14 13:25 private_key.json
-rw-r--r-- 1 root root   86 Jul 14 13:25 regr.json

/etc/letsencrypt/accounts/acme-v02.api.letsencrypt.org:
total 12
drwx------ 3 root root 4096 Jul 14 10:22 .
drwx------ 4 root root 4096 Jul 14 13:25 ..
drwx------ 3 root root 4096 Jul 14 10:22 directory

/etc/letsencrypt/accounts/acme-v02.api.letsencrypt.org/directory:
total 12
drwx------ 3 root root 4096 Jul 14 10:22 .
drwx------ 3 root root 4096 Jul 14 10:22 ..
drwx------ 2 root root 4096 Jul 14 10:22 84d798c657d902ca972115f698a7dfb6

/etc/letsencrypt/accounts/acme-v02.api.letsencrypt.org/directory/84d798c657d902ca972115f698a7dfb6:
total 20
drwx------ 2 root root 4096 Jul 14 10:22 .
drwx------ 3 root root 4096 Jul 14 10:22 ..
-rw-r--r-- 1 root root   80 Jul 14 10:22 meta.json
-r-------- 1 root root 1632 Jul 14 10:22 private_key.json
-rw-r--r-- 1 root root   79 Jul 14 10:22 regr.json

/etc/letsencrypt/archive:
total 12
drwx------ 3 root root 4096 Jul 15 16:48 .
drwxr-xr-x 9 root root 4096 Jul 15 21:49 ..
drwxr-xr-x 2 root root 4096 Jul 15 16:48 biggszm.duckdns.org

/etc/letsencrypt/archive/biggszm.duckdns.org:
total 28
drwxr-xr-x 2 root root 4096 Jul 15 16:48 .
drwx------ 3 root root 4096 Jul 15 16:48 ..
-rw-r--r-- 1 root root 1854 Jul 15 16:48 cert1.pem
-rw-r--r-- 1 root root 3749 Jul 15 16:48 chain1.pem
-rw-r--r-- 1 root root 5603 Jul 15 16:48 fullchain1.pem
-rw------- 1 root root 1704 Jul 15 16:48 privkey1.pem

/etc/letsencrypt/csr:
total 44
drwxr-xr-x 2 root root 4096 Jul 15 16:48 .
drwxr-xr-x 9 root root 4096 Jul 15 21:49 ..
-rw-r--r-- 1 root root  932 Jul 14 10:23 0000_csr-certbot.pem
-rw-r--r-- 1 root root  932 Jul 14 10:26 0001_csr-certbot.pem
-rw-r--r-- 1 root root  936 Jul 14 10:41 0002_csr-certbot.pem
-rw-r--r-- 1 root root  932 Jul 14 10:41 0003_csr-certbot.pem
-rw-r--r-- 1 root root  932 Jul 14 11:40 0004_csr-certbot.pem
-rw-r--r-- 1 root root  932 Jul 14 13:23 0005_csr-certbot.pem
-rw-r--r-- 1 root root  932 Jul 15 07:46 0006_csr-certbot.pem
-rw-r--r-- 1 root root  936 Jul 15 07:46 0007_csr-certbot.pem
-rw-r--r-- 1 root root  932 Jul 15 16:48 0008_csr-certbot.pem

/etc/letsencrypt/keys:
total 44
drwx------ 2 root root 4096 Jul 15 16:48 .
drwxr-xr-x 9 root root 4096 Jul 15 21:49 ..
-rw------- 1 root root 1704 Jul 14 10:23 0000_key-certbot.pem
-rw------- 1 root root 1704 Jul 14 10:26 0001_key-certbot.pem
-rw------- 1 root root 1704 Jul 14 10:41 0002_key-certbot.pem
-rw------- 1 root root 1704 Jul 14 10:41 0003_key-certbot.pem
-rw------- 1 root root 1708 Jul 14 11:40 0004_key-certbot.pem
-rw------- 1 root root 1704 Jul 14 13:23 0005_key-certbot.pem
-rw------- 1 root root 1704 Jul 15 07:46 0006_key-certbot.pem
-rw------- 1 root root 1704 Jul 15 07:46 0007_key-certbot.pem
-rw------- 1 root root 1704 Jul 15 16:48 0008_key-certbot.pem

/etc/letsencrypt/live:
total 16
drwx------ 3 root root 4096 Jul 15 16:48 .
drwxr-xr-x 9 root root 4096 Jul 15 21:49 ..
drwxr-xr-x 2 root root 4096 Jul 15 16:48 biggszm.duckdns.org
-rw-r--r-- 1 root root  740 Jul 14 13:24 README

/etc/letsencrypt/live/biggszm.duckdns.org:
total 12
drwxr-xr-x 2 root root 4096 Jul 15 16:48 .
drwx------ 3 root root 4096 Jul 15 16:48 ..
lrwxrwxrwx 1 root root   43 Jul 15 16:48 cert.pem -> ../../archive/biggszm.duckdns.org/cert1.pem
lrwxrwxrwx 1 root root   44 Jul 15 16:48 chain.pem -> ../../archive/biggszm.duckdns.org/chain1.pem
lrwxrwxrwx 1 root root   48 Jul 15 16:48 fullchain.pem -> ../../archive/biggszm.duckdns.org/fullchain1.pem
lrwxrwxrwx 1 root root   46 Jul 15 16:48 privkey.pem -> ../../archive/biggszm.duckdns.org/privkey1.pem
-rw-r--r-- 1 root root  692 Jul 15 16:48 README

/etc/letsencrypt/renewal:
total 12
drwxr-xr-x 2 root root 4096 Jul 15 16:48 .
drwxr-xr-x 9 root root 4096 Jul 15 21:49 ..
-rw-r--r-- 1 root root  673 Jul 15 16:48 biggszm.duckdns.org.conf

/etc/letsencrypt/renewal-hooks:
total 20
drwxr-xr-x 5 root root 4096 Jul 14 10:22 .
drwxr-xr-x 9 root root 4096 Jul 15 21:49 ..
drwxr-xr-x 2 root root 4096 Jul 14 10:22 deploy
drwxr-xr-x 2 root root 4096 Jul 14 10:22 post
drwxr-xr-x 2 root root 4096 Jul 14 10:22 pre

/etc/letsencrypt/renewal-hooks/deploy:
total 8
drwxr-xr-x 2 root root 4096 Jul 14 10:22 .
drwxr-xr-x 5 root root 4096 Jul 14 10:22 ..

/etc/letsencrypt/renewal-hooks/post:
total 8
drwxr-xr-x 2 root root 4096 Jul 14 10:22 .
drwxr-xr-x 5 root root 4096 Jul 14 10:22 ..

/etc/letsencrypt/renewal-hooks/pre:
total 8
drwxr-xr-x 2 root root 4096 Jul 14 10:22 .
drwxr-xr-x 5 root root 4096 Jul 14 10:22 ..
sudo ls -lRa /etc/apache2/sites-available
/etc/apache2/sites-available:
total 28
drwxr-xr-x 2 root root 4096 Jul 15 16:57 .
drwxr-xr-x 8 root root 4096 Jul 15 16:57 ..
-rw-r--r-- 1 root root 1332 Apr 13  2020 000-default.conf
-rw-r--r-- 1 root root 6338 Apr 13  2020 default-ssl.conf
-rw-r--r-- 1 root root 3345 Jul 15 16:57 zm.conf
-rw-r--r-- 1 root root 3358 Jul 15 16:57 zm-le-ssl.conf
sudo ls -lRa /etc/apache2/sites-enabled
/etc/apache2/sites-enabled:
total 8
drwxr-xr-x 2 root root 4096 Jul 15 16:57 .
drwxr-xr-x 8 root root 4096 Jul 15 16:57 ..
lrwxrwxrwx 1 root root   26 Jul 14 22:20 zm.conf -> ../sites-available/zm.conf
lrwxrwxrwx 1 root root   43 Jul 15 16:57 zm-le-ssl.conf -> /etc/apache2/sites-available/zm-le-ssl.conf
1 Like

@biggs, did you shutdown the web server (or did the IP change)?
[it no longer responds]

1 Like

It is up for me. Are you accessing it on port 8080? biggszm.duckdns.org:8080

1 Like

I did not try 8080 - that is up.
But since you still need to get a cert with both names on it, you will need to enable 80.
[and you will need 80 open to renew the certs (every 60 days)]

1 Like

Public port 80 is blocked by my ISP. That is why earlier in the conversation I was told to use a DNS-01 challenge instead of a HTTP-01. Unless you mean I need to unblock private port 80, but I don't think that is what you mean.

1 Like

OK I must have missed/forgot that :frowning:
Nonetheless, you have to overcome this problem:

curl -I https://www.biggszm.duckdns.org
curl: (51) SSL: no alternative certificate subject name matches target host name 'www.biggszm.duckdns.org'

There are four possible connections:

http://biggszm.duckdns.org/      [ISP blocks 80 - but works via 8080]
http://www.biggszm.duckdns.org/  [ISP blocks 80 - but works via 8080]
https://biggszm.duckdns.org/     [WORKS]
https://www.biggszm.duckdns.org/ [FAILS - No matching name in cert]
1 Like

Hmm that is at least better than before. I have HTTPS on ZM - Login now. This was not the case before.

1 Like

Better than nothing (I suppose).
But ideally you would have both names on the cert and have the renewals fully automated.
Not sure if you are willing to put in the extra work to get any of that done.

EDIT: Two individual certs could also work - but you would have to split the file zm-le-ssl.conf in two.

1 Like

Not sure how I should accomplish that. Since I am using a DNS-01 challenge, I must use a plugin for my DNS provider on certbot. I am using certbot-dns-duckdns plugin which can be found here: certbot-dns-duckdns · PyPI. I would have to issue 2 certs per the documentation. I guess I could also issue a wildcard cert too though right?

1 Like

Try splitting the file into something like this:

<VirtualHost *:443>
        ServerName biggszm.duckdns.org

        ServerAdmin webmaster@localhost
        DocumentRoot /usr/share/zoneminder/www

        # Remember to enable cgi mod (i.e. "a2enmod cgi").
        ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
        <Directory "/usr/lib/zoneminder/cgi-bin">
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            AllowOverride All
            Require all granted
        </Directory>

        # Order matters. This alias must come first.
        Alias /zm/cache /var/cache/zoneminder/cache
        <Directory /var/cache/zoneminder/cache>
            Options -Indexes +FollowSymLinks
            AllowOverride None
            <IfModule mod_authz_core.c>
                # Apache 2.4
                Require all granted
            </IfModule>
        </Directory>

        Alias /zm /usr/share/zoneminder/www
        <Directory /usr/share/zoneminder/www>
            Options -Indexes +FollowSymLinks
            <IfModule mod_dir.c>
                DirectoryIndex index.php
            </IfModule>
        </Directory>

        # For better visibility, the following directives have been migrated from the
        # default .htaccess files included with the CakePHP project.
        # Parameters not set here are inherited from the parent directive above.
        <Directory "/usr/share/zoneminder/www/api">
            RewriteEngine on
            RewriteRule ^$ app/webroot/ [L]
            RewriteRule (.*) app/webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app">
            RewriteEngine on
            RewriteRule ^$ webroot/ [L]
            RewriteRule (.*) webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app/webroot">
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
            RewriteBase /zm/api
        </Directory>


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateFile    /etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem # domain cert
  SSLCertificateKeyFile /etc/letsencrypt/live/biggszm.duckdns.org/privkey.pem   # domain key
</VirtualHost>

<VirtualHost *:443>
        ServerName www.biggszm.duckdns.org

        ServerAdmin webmaster@localhost
        DocumentRoot /usr/share/zoneminder/www

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine On
    RewriteRule ^/?(.*) https://biggszm.duckdns.org/$1

  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateFile    /etc/letsencrypt/live/www.biggszm.duckdns.org/fullchain.pem # www cert
  SSLCertificateKeyFile /etc/letsencrypt/live/www.biggszm.duckdns.org/privkey.pem   # www key
</VirtualHost>
1 Like

Then you can run certbot twice - once for each FQDN.

1 Like

Ok I think it works now? I generated and installed a cert for www.biggszm.duckdns.org. Your conf file didn't work because of the trailing line comments on the second vhost so I removed them and Apache restarted. This is what I have now:

sudo certbot certificates
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
  Certificate Name: biggszm.duckdns.org
    Serial Number: 3ffb3d213dab9964367d72ccf063f9b79b3
    Key Type: RSA
    Domains: biggszm.duckdns.org
    Expiry Date: 2021-10-13 20:48:08+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/biggszm.duckdns.org/privkey.pem
  Certificate Name: www.biggszm.duckdns.org
    Serial Number: 46839b0deece22f984325784783fd092ede
    Key Type: RSA
    Domains: www.biggszm.duckdns.org
    Expiry Date: 2021-10-14 02:34:39+00:00 (VALID: 89 days)
    Certificate Path: /etc/letsencrypt/live/www.biggszm.duckdns.org/fullchain.pem
    Private Key Path: /etc/letsencrypt/live/www.biggszm.duckdns.org/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cat zm-le-ssl.conf 
<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName biggszm.duckdns.org

        ServerAdmin webmaster@localhost
        DocumentRoot /usr/share/zoneminder/www

        # Remember to enable cgi mod (i.e. "a2enmod cgi").
        ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin"
        <Directory "/usr/lib/zoneminder/cgi-bin">
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            AllowOverride All
            Require all granted
        </Directory>


        # Order matters. This alias must come first.
        Alias /zm/cache /var/cache/zoneminder/cache
        <Directory /var/cache/zoneminder/cache>
            Options -Indexes +FollowSymLinks
            AllowOverride None
            <IfModule mod_authz_core.c>
                # Apache 2.4
                Require all granted
            </IfModule>
        </Directory>

        Alias /zm /usr/share/zoneminder/www
        <Directory /usr/share/zoneminder/www>
            Options -Indexes +FollowSymLinks
            <IfModule mod_dir.c>
                DirectoryIndex index.php
            </IfModule>
        </Directory>

        # For better visibility, the following directives have been migrated from the
        # default .htaccess files included with the CakePHP project.
        # Parameters not set here are inherited from the parent directive above.
        <Directory "/usr/share/zoneminder/www/api">
            RewriteEngine on
            RewriteRule ^$ app/webroot/ [L]
            RewriteRule (.*) app/webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app">
            RewriteEngine on
            RewriteRule ^$ webroot/ [L]
            RewriteRule (.*) webroot/$1 [L]
            RewriteBase /zm/api
        </Directory>

        <Directory "/usr/share/zoneminder/www/api/app/webroot">
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
            RewriteBase /zm/api
        </Directory>


        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/biggszm.duckdns.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/biggszm.duckdns.org/privkey.pem
</VirtualHost>

<VirtualHost *:443>
        ServerName www.biggszm.duckdns.org

        ServerAdmin webmaster@localhost
        DocumentRoot /usr/share/zoneminder/www

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

    RewriteEngine On
    RewriteRule ^/?(.*) https://biggszm.duckdns.org/$1

  Include /etc/letsencrypt/options-ssl-apache.conf
  SSLCertificateFile    /etc/letsencrypt/live/www.biggszm.duckdns.org/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/www.biggszm.duckdns.org/privkey.pem
</VirtualHost>

</IfModule>
sudo apachectl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443                  is a NameVirtualHost
         default server biggszm.duckdns.org (/etc/apache2/sites-enabled/zm-le-ssl.conf:2)
         port 443 namevhost biggszm.duckdns.org (/etc/apache2/sites-enabled/zm-le-ssl.conf:2)
         port 443 namevhost www.biggszm.duckdns.org (/etc/apache2/sites-enabled/zm-le-ssl.conf:91)
*:80                   www.biggszm.duckdns.org (/etc/apache2/sites-enabled/zm.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33
2 Likes

Did you miss this part?

You should be able to run this now:

sudo certbot --cert-name combined --apache -d "biggszm.duckdns.org,www.biggszm.duckdns.org"

Should I do that even though I have two certs now with the split conf file now? Or should I go back to the conf file with an alias and a single cert before I issue that command?

1 Like

Since you're using certbot-dns-duckdns · PyPI, it might be easier to have the two certificates at this point since both can be easily automated. You need to use the duckdns authenticator plugin and the apache installer.

Something like this:

sudo certbot --preferred-challenges dns -a dns-duckdns --dns-duckdns-token <your-duckdns-token> --dns-duckdns-propagation-seconds 60 -d "biggszm.duckdns.org" -i apache

sudo certbot --preferred-challenges dns -a dns-duckdns --dns-duckdns-token <your-duckdns-token> --dns-duckdns-propagation-seconds 60 -d "www.biggszm.duckdns.org" -i apache