Nextcloud, website and subdomains

On a headless server you can run the scripts: https://docs.hanssonit.se/s/bj0vl1ihv0jgrmfm08j0/build-your-own/d/bj0vl4ahv0jgrmfm0950/nextcloud-vm

One should not run a server in VMware Player or similar.

This error is saying it can’t connect to port 8080 on your system. Have you changed the port number? Can you access port 8080 directly?

Would be interesting why?

1 Like

UPDATE. With huge thanks to @KarlF12.

Well, It would appear that I have got Apache2 and its virtual hosts all sorted. My domain now points successfully to my webroot and is redirected to the https version automatically. On the snap/nextcloud side, that also has https installed and according to snap is listening on ports 8080 and 8443. The following “curl trail” shows that cloud.domain.tld is definitely being properly forwarded to :8443 as it should be:

derek@derek-desktop ~ $ curl cloud.badbury.org.uk
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://cloud.badbury.org.uk/">here</a>.</p>
<hr>
<address>Apache/2.4.41 (Ubuntu) Server at cloud.badbury.org.uk Port 80</address>
</body></html>
derek@derek-desktop ~ $ curl https://cloud.badbury.org.uk
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https://cloud.badbury.org.uk:8443/">here</a>.</p>
</body></html>
derek@derek-desktop ~ $ curl https://cloud.badbury.org.uk:8443
curl: (7) Failed to connect to cloud.badbury.org.uk port 8443: Connection refused
derek@derek-desktop ~ $ 

So, it would appear that the request is being forwarded to the right port but that port is refusing the connection. The same message is delivered when using a browser to try to connect:

Unable to connect
Firefox can’t establish a connection to the server at cloud.badbury.org.uk:8443.

Is there any way of finding out ON WHAT GROUNDS the connection is being refused by snap/nextcloud?

I’m suspecting that it is seen as coming from an untrusted domain? Am I missing something obvious here? Below is a copy of nextcloud’s config.php (sensitive info munged):

<?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,
  ),
  'passwordsalt' => 'munged',
  'secret' => 'munged',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => 'cloud.badbury.org.uk',
  ),
  'datadirectory' => '/var/snap/nextcloud/common/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '19.0.1.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:/tmp/sockets/mysql.sock',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'munged',
  'installed' => true,
  'instanceid' => 'munged',
  'maintenance' => false,
);

Connection refused is a TCP error. Most often this means you connected to a port that isn’t in the listening state (wrong address, service not running, etc.).

Confirm that the snap is running and that the port is indeed open (netstat -lntp).

The idea with the reverse proxy is that the client accesses Apache on port 443, and Apache proxies the connection to the snap on port 8080 or 8443. The client should not be redirected to 8443 directly. Can you show your current Apache sure config?