Not able to run nextcloud.enable-https lets-encrypt

Nextcloud version (eg, 20.0.5): 24.0.1snap1 (installed via snap)
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04 (LXC Container hosted on Proxmox)
Apache or nginx version (eg, Apache 2.4.25): don't know (installed via snap)
PHP version (eg, 7.4): don't know (installed via snap)

The issue you are facing:
nextcloud.enable-https lets-encrypt doesn’t seem to work (the commands keeps running but there is no output).

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

Steps to replicate it:

  1. Deploy LXC Container (Ubuntu)
  2. Install nextcloud snap package
  3. Install and configure nextcloud :
    • nextcloud.manual-install <user> <password>
    • nextcloud.occ config:system:set trusted_domains 1 --value=<nextcloud IP>=> At this step, I’m able to log in on Nextcloud webpage. Everything seems to work (through HTTP though)
    • nextcloud.enable-https lets-encrypt => this command keeps running and nothing happens (no output, no error). i’m able to cancel the command (Ctrl+C).

The output of your Nextcloud log in Admin > Logging:

{"reqId":"Y6ZrVLcOTR37bDCeqsKu","level":2,"time":"2022-07-13T14:26:18+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"ylDCQPhPejqJDeDp4fXV","level":2,"time":"2022-07-13T14:26:23+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/index.php/js/core/merged-template-prepend.js?v=83e9abba","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"Ufsq0AuqDeFzBzXhtHWQ","level":2,"time":"2022-07-13T14:26:27+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/cron.php","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"LI97MajkVw8kG69IInVK","level":2,"time":"2022-07-13T14:27:03+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"yApZJFgzZjHlFyBD3XbP","level":2,"time":"2022-07-13T14:27:06+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/index.php/js/core/merged-template-prepend.js?v=83e9abba","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"XgAZkS5EvWAbs0Pr2DXG","level":2,"time":"2022-07-13T14:27:08+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/cron.php","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"06obsJ27MdPr8uJMW2D6","level":2,"time":"2022-07-13T14:34:50+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"nPZB7MvGJpdApHrWUSaH","level":2,"time":"2022-07-13T14:34:55+00:00","remoteAddr":"192.168.1.42","user":"--","app":"core","method":"GET","url":"/index.php/js/core/merged-template-prepend.js?v=83e9abba","message":"Trusted domain error. \"192.168.1.42\" tried to access using \"192.168.1.63\" as host.","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}
{"reqId":"XzW8q5dwEPSCxkiP1DIC","level":3,"time":"2022-07-13T14:40:09+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Trying to access array offset on value of type null at /snap/nextcloud/31033/htdocs/apps/dav/lib/CalDAV/BirthdayService.php#306","userAgent":"--","version":"24.0.1.1","exception":{"Exception":"Error","Message":"Trying to access array offset on value of type null at /snap/nextcloud/31033/htdocs/apps/dav/lib/CalDAV/BirthdayService.php#306","Code":0,"Trace":[{"file":"/snap/nextcloud/31033/htdocs/apps/dav/lib/CalDAV/BirthdayService.php","line":306,"function":"onError","class":"OC\\Log\\ErrorHandler","type":"::"},{"file":"/snap/nextcloud/31033/htdocs/apps/dav/lib/BackgroundJob/GenerateBirthdayCalendarBackgroundJob.php","line":70,"function":"resetForUser","class":"OCA\\DAV\\CalDAV\\BirthdayService","type":"->"},{"file":"/snap/nextcloud/31033/htdocs/lib/public/BackgroundJob/Job.php","line":79,"function":"run","class":"OCA\\DAV\\BackgroundJob\\GenerateBirthdayCalendarBackgroundJob","type":"->"},{"file":"/snap/nextcloud/31033/htdocs/lib/public/BackgroundJob/QueuedJob.php","line":47,"function":"execute","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/snap/nextcloud/31033/htdocs/cron.php","line":151,"function":"execute","class":"OCP\\BackgroundJob\\QueuedJob","type":"->"}],"File":"/snap/nextcloud/31033/htdocs/lib/private/Log/ErrorHandler.php","Line":92,"CustomMessage":"--"}}
{"reqId":"MpyWrmcaJWkXVa21JqCM","level":2,"time":"2022-07-13T17:55:11+00:00","remoteAddr":"192.168.1.43","user":"--","app":"no app in context","method":"POST","url":"/index.php/login","message":"Login failed: root (Remote IP: 192.168.1.43)","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36","version":"24.0.1.1"}

The output of your Apache/nginx/system log in /var/snap/nextcloud/current/nextcloud/config/config.php:


<?php
$CONFIG = array (
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/snap/nextcloud/current/htdocs/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/snap/nextcloud/current/nextcloud/extra-apps',
      'url' => '/extra-apps',
      'writable' => true,
    ),
  ),
  'supportedDatabases' => 
  array (
    0 => 'mysql',
  ),
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/tmp/sockets/redis.sock',
    'port' => 0,
  ),
  'log_type' => 'file',
  'logfile' => '/var/snap/nextcloud/current/logs/nextcloud.log',
  'logfilemode' => 416,
  'passwordsalt' => 'CENSURED',
  'secret' => 'CENSURED',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '192.168.1.63',
  ),
  'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.1.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'CENSURED',
  'dbpassword' => 'CENSURED',
  'installed' => true,
  'instanceid' => 'CENSURED',
  'trusted_domain' => 
  array (
    1 => '192.168.1.63',
  ),
  'maintenance' => false,
);

Thanks a lot for your help!

Letsencrypt only works with a public URI of your Nextcloud (f.e. “myhost.mydomain.net”. The public URI needs to be added to trusted_domains
In addition port 80 and 443 need to be forwarded from internet to your Nextcloud.

1 Like

Thanks for your answer.

Yes I know. I just forgot to add the FQDN to the list but that’s not what caused the problem. The missing trusted domain in this array would have caused an error at the time of trying to reach the nextcloud server, but not at the time of executing the lets-encrypt script.

Anyway, I found the issue.
I was accessing the terminal through an integrated console in Proxmox. It seems that this feature has some bugs because when I access the nextcloud server through another terminal via SSH, it works well.

Thanks!