Certbot fails/apache default page appears

[/details]

Nextcloud version (eg, 12.0.2): 16.0.0
Operating system and version (eg, Ubuntu 17.04): 18.04.02
Apache or nginx version (eg, Apache 2.4.25): 2.4.29
PHP version (eg, 7.1): 7.2

The issue you are facing:

  1. cerbot not working
  2. my.ddns.net gets me to apache default page

Is this the first time you’ve seen this error? (Y/N):
N
Steps to replicate it:

  1. cerbot --apache gets me
    certbot --apache
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Plugins selected: Authenticator apache, Installer apache

     Which names would you like to activate HTTPS for?
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     1: countomega.dnshome.de
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     Select the appropriate numbers separated by commas and/or spaces, or leave input
     blank to select all options shown (Enter 'c' to cancel): 1
     Obtaining a new certificate
     Performing the following challenges:
     http-01 challenge for countomega.dnshome.de
     Waiting for verification...
     Cleaning up challenges
     Failed authorization procedure. countomega.dnshome.de (http-01): urn:ietf:params:acme:error:unauthorized :: The client lacks sufficient authorization :: Invalid response from http://countomega.dnshome.de/.well-known/acme-challenge/8W8-ySt0jfWrgDZGasMUwdajXekahAIgMShLpDWyASs [93.212.151.36]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>404 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"
    
     IMPORTANT NOTES:
      - The following errors were reported by the server:
    
        Domain: countomega.dnshome.de
        Type:   unauthorized
        Detail: Invalid response from
        http://countomega.dnshome.de/.well-known/acme-challenge/8W8-ySt0jfWrgDZGasMUwdajXekahAIgMShLpDWyASs
        [93.212.151.36]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML
        2.0//EN\">\n<html><head>\n<title>404 Not
        Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"
    
            To fix these errors, please make sure that your domain name was
        entered correctly and the DNS A/AAAA record(s) for that domain
        contain(s) the right IP address.
    

The output of your Nextcloud log in Admin > Logging:


The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'id',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' =>
  array (
    0 => '192.168.178.68',
    1 => 'countomega.dnshome.de'
  ),
  'datadirectory' => '/home/rock64/nextcloud-files',
  'dbtype' => 'mysql',
  'version' => '16.0.1.1',
  'overwrite.cli.url' => 'http://192.168.178.68',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'user',
  'dbpassword' => 'pw',
  'installed' => true,
  'activity_expire_days' => 14,
  'auth.bruteforce.protection.enabled' => true,
  'blacklisted_files' =>
        array (                                                                                                                                                                                                                                                      0 => '.htaccess',                                                                                                                                                                                                                                            1 => 'Thumbs.db',                                                                                                                                                                                                                                            2 => 'thumbs.db',
        ),
  'cron_log' => true,
  'enable_previews' => true,
  'enabledPreviewProviders' =>
        array (
        0 => 'OC\\Preview\\PNG',
        1 => 'OC\\Preview\\JPEG',
        2 => 'OC\\Preview\\GIF',
        3 => 'OC\\Preview\\BMP',
        4 => 'OC\\Preview\\XBitmap',
        5 => 'OC\\Preview\\Movie',
        6 => 'OC\\Preview\\PDF',
        7 => 'OC\\Preview\\MP3',
        8 => 'OC\\Preview\\TXT',
        9 => 'OC\\Preview\\MarkDown',
        ),
  'filesystem_check_changes' => 0,
  'filelocking.enabled' => 'true',
  'htaccess.RewriteBase' => '/',
  'integrity.check.disabled' => false,
  'knowledgebaseenabled' => false,
  'logfile' => '/var/nc_data/nextcloud.log',
  'loglevel' => 2,
  'logtimezone' => 'Europe/Berlin',
  'log_rotate_size' => 104857600,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'overwriteprotocol' => 'https',
  'preview_max_x' => 1024,
  'preview_max_y' => 768,
  'preview_max_scale_factor' => 1,
  'redis' =>
        array (
        'host' => '/var/run/redis/redis-server.sock',
        'port' => 0,
        'timeout' => 0.0,
        ),
  'quota_include_external_storage' => false,
  'share_folder' => '/Shares',
  'skeletondirectory' => '',
  'theme' => '',
  'trashbin_retention_obligation' => 'auto, 7',
  'updater.release.channel' => 'stable',

);

The output of your Apache/nginx/system log in /var/log/____:


IMHO Certbot needs port 80 and 443 open and redirect for working. Is ACME supported by ddns.net?

Port 80 and 443 are both open on ipv4/6 on my router. I don´t know if acme is supported.

Ask your DynDNS Provider. If not available, try https://www.ddnss.de/
It works for me without any problems with Debian 9 / Certbot. Take a look at your vHost config, perhaps mispell or syntax error.

Thanks I´ll try that.

Thanks for you response.
Still no luck. apachectl -t gets me sytax ok, but apachectl -S says that my DocumentRoot is /var/www/html instead of nextcloud despite I changed the files accordingly. Any ideas?

Certbot errors the same or others?

My vHost def BEFORE i set the certbot cert:

<VirtualHost *:80>"

Servername nextcloud.“my-DynDNS-FQDN”.de"
Loglevel debug

and set a2enable this sub domain.

First of all you can try to set the Letsencrypt cert with certbot to your FQDN from your DynDNS Provider. I am using Debian 9 sid, Apache2.4.38 and certbot 0.31.0-1

I’m getting the same errors as before. I read that certbot doesn’t work with Dyn DNS services and that you have to ask the provider e.g. dnshome.de for certification. I’ll try your solution soon as I get home. Thanks

Of course works certbot with DynDNS, i use it since a few months, really. This solution is ACME as i tell you above.

Stiil no luck. certbot --apache -d countomega.ddnss.de throws same old error.
Here my vhost conf, if it helps:

<VirtualHost *:80>
ServerAdmin Matthias@countomega.ddnss.de
DocumentRoot /var/www/nextcloud
ServerName nextcloud.countomega.ddnss.de
RewriteEngine on RewriteCond %{SERVER_NAME} =countomega.ddnss.de
RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Alias /.well-known/acme-challenge/ /var/www/letsencrypt/.well-known/acme-challenge/ <Directory "/var/www/letsencrypt/.well-known/acme-challenge/">
Options None
AllowOverride None
ForceType text/plain
RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)"
</Directory>
Loglevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

<VirtualHost *:443>
ServerAdmin Matthias@countomega.ddnss.de
DocumentRoot /var/www/nextcloud
ServerName countomega.ddnss.de
RewriteEngine on
RewriteCond %{SERVER_NAME} =countomega.ddnss.de
RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Alias /.well-known/acme-challenge/ /var/www/letsencrypt/.well-known/acme-challenge/
<Directory "/var/www/letsencrypt/.well-known/acme-challenge/">
Options None
AllowOverride None
RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)"
 </Directory>
                                                                                                                                                                                                                                                                   #  <IfModule mod_headers.c>
           #   Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
          # </IfModule>
    </VirtualHost>