No Access to NC-webui (and NCP-webui) - NooB

Nextcloud version: 1.29.8
Operating system and version: Raspbian GNU/Linux 10 (buster)
Apache or nginx version: Apache 2.4 .23
PHP version: 7.3

The issue you are facing:
No access to WebUI or NCP-WebUI! In the past I had random access, but now web access is completely lost.
WebUI:

Interner Serverfehler
Der Server konnte die Anfrage nicht fertig stellen.
Sollte dies erneut auftreten, sende bitte die nachfolgenden technischen Einzelheiten an Deinen Server-Administrator.
Weitere Details können im Server-Protokoll gefunden werden.
Technische Details
    Entfernte Adresse: 2a01:c22:b42c:a700:8561:1c42:7c1d:e35
    Anfragekennung: X1SWWN6dPxHzJyDV@JG-7QAAVh8

Access via Windows and Android app is to be still open.

NCP-WebUI:

Forbidden
You don't have permission to access this resource.

Is this the first time you’ve seen this error? : No
Problems occurs repeatedly, ramdom for long time, now continued.
Be trying to move ncdata and ncdatabase fom HDD to SSD.

Steps to replicate it:
Any access to WEBUI

The output of your Nextcloud log in Admin > Logging:

Not accessible

The output of your config.php file in `/path/to/nextcloud:

EDIT: obviousliy ignored config:
From /var/www/html//nextcloud/config/config.php

<?php
$CONFIG = array (
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    11 => '77.189.87.41',
    1 => '192.168.178.4',
    5 => 'nextcloudpi.local',
    7 => 'nextcloudpi',
    8 => 'nextcloudpi.lan',
    20 => 'xxxxxxserver',
    21 => '192.168.178.4',
    22 => 'xxx.xxxx-server.de',
    12 => 'xxx.xxxx-server.de',
  ),
  'datadirectory' => '/media/USBdrive/ncdata',
  'dbtype' => 'mysql',
  'version' => '18.0.5.1',
  'overwrite.cli.url' => 'https://xxx-xxxx-server.de/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncadmin',
  'dbpassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'installed' => true,
  'instanceid' => 'ocrjcy6hgo8f',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
    'password' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  ),
  'tempdirectory' => '/media/USBdrive/ncdata/tmp',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'xxxxxxxxxxxxxxxxx',
  'mail_domain' => 'xxxxxxxxx.com',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'filesystem_check_changes' => '1',
  'overwriteprotocol' => 'https',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'smtp.xxxxxxxxxxxxxxx.com',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '587',
  'mail_smtpname' => 'xxxxxxxxxxxxxxxxxxx@xxxxxxxx.xxx',
  'mail_smtppassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'maintenance' => false,
  'htaccess.RewriteBase' => '/',
  'logfile' => '/media/USBdrive/ncdata/nextcloud.log',
  'loglevel' => '2',
  'log_type' => 'file',
);

EDIT: obviousliy VALID config:
From /var/www/nextcloud/config/config.php (I have no clue which one is used!!)

<?php
$CONFIG = array (
  'passwordsalt' => 'xxxxxxxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '192.168.178.4',
    5 => 'nextcloudpi.local',
    7 => 'nextcloudpi',
    8 => 'nextcloudpi.lan',
    20 => 'xxxxxxxxxxxxserver',
    12 => 'xxxxxxxxxxxxxxx-server.de',
    11 => '77.12.90.24',
    21 => '192.168.178.4',
    22 => 'xxxxxxxxxxxxxxx-server.de',
  ),
  'datadirectory' => '/media/SSD/ncdata',
  'dbtype' => 'mysql',
  'version' => '19.0.2.2',
  'overwrite.cli.url' => 'https://xxxxxxx-server.de/',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncadmin',
  'dbpassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'installed' => true,
  'instanceid' => 'xxxxxxxxxxxxxxxxx',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
    'password' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  ),
  'tempdirectory' => '/media/SSD/ncdata/tmp',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'xxxxxxxxxxxxxxxxx',
  'mail_domain' => 'xxxxxxxxxxxxxxxxxx',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'filesystem_check_changes' => '1',
  'overwriteprotocol' => 'https',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'xxxxxxxxxxxxxxxxxx',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '587',
  'mail_smtpname' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'mail_smtppassword' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'maintenance' => false,
  'htaccess.RewriteBase' => '/',
  'logfile' => '/media/SSD/ncdata/nextcloud.log',
  'loglevel' => '2',
  'log_type' => 'file',
  'data-fingerprint' => 'xxxxxxxxxxxxxxxxxxxxxxx',
);

The output of your Apache system log in:
Apache2 error log

[Sat Sep 05 11:09:41.443595 2020] [ssl:warn] [pid 1013:tid 3069473296] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Sat Sep 05 11:09:41.443918 2020] [ssl:error] [pid 1013:tid 3069473296] AH02217: ssl_stapling_init_cert: can't retrieve issuer certificate! [subject: CN=raspberrypi / issuer: CN=raspberrypi / serial: 353B66BC904E0A412BC933C8B6B95A185CC70E21 / notbefore: Nov 23 10:01:48 2019 GMT / notafter: Nov 20 10:01:48 2029 GMT]
[Sat Sep 05 11:09:41.443944 2020] [ssl:error] [pid 1013:tid 3069473296] AH02604: Unable to configure certificate localhost:4443:0 for stapling
[Sat Sep 05 11:09:41.449875 2020] [mpm_event:notice] [pid 1013:tid 3069473296] AH00489: Apache/2.4.38 (Raspbian) OpenSSL/1.1.1d configured -- resuming normal operations
[Sat Sep 05 11:09:41.449920 2020] [core:notice] [pid 1013:tid 3069473296] AH00094: Command line: '/usr/sbin/apache2'
[Sun Sep 06 08:12:10.486742 2020] [authz_core:error] [pid 2245:tid 2948264992] [client 2a01:c22:b42c:a700:8561:1c42:7c1d:e35:50471] AH01630: client denied by server configuration: /var/www/ncp-web/
[Sun Sep 06 08:12:10.528959 2020] [authz_core:error] [pid 2245:tid 2948264992] [client 2a01:c22:b42c:a700:8561:1c42:7c1d:e35:50471] AH01630: client denied by server configuration: /var/www/ncp-web/favicon.ico
[Sun Sep 06 08:31:27.211779 2020] [authz_core:error] [pid 2246:tid 2872730656] [client 2a01:c22:b42c:a700:8561:1c42:7c1d:e35:51820] AH01630: client denied by server configuration: /var/www/ncp-web/
[Sun Sep 06 09:59:55.181475 2020] [authz_core:error] [pid 2246:tid 2755232800] [client 2a01:c22:b42c:a700:8561:1c42:7c1d:e35:54388] AH01630: client denied by server configuration: /var/www/ncp-web/
[Sun Sep 06 09:59:55.337918 2020] [authz_core:error] [pid 2246:tid 2755232800] [client 2a01:c22:b42c:a700:8561:1c42:7c1d:e35:54388] AH01630: client denied by server configuration: /var/www/ncp-web/favicon.ico

In /var/log/syslog I find no related contents. How to find/filter something here??

Wouldn’t it be easier if you know what you were doing.

You have 2 NC directories and you do not know which one is used how do we suppose to know.?

what does this mean in The issue you are facing?

 In the past random access, now follw lost.

and what does this mean between your logs

Access via Windows and Android app is to be still open.

why do you use random numbers in your trusted domains

your DATA-DIR is eighter here
'datadirectory' => '/media/USBdrive/ncdata',
or here
'datadirectory' => '/media/SSD/ncdata',

besides that you do not know where you configured nextcloud you have setup you apache wrong.

fix your ssl warn and errors first which are not NC related

or try not to use SSL and not overwrite cli url to https

'overwrite.cli.url' => 'http://xxxxxxx-server.de/',

and for your answer to

In /var/log/syslog I find no related contents. How to find/filter something here??

use cat file | grep string

FIX apache first

Thanks for your answer!

In fact, I can’t find out what happend. I tried to repair the config serveral time. Now, I end up with more and more problems.
And I am really sick of all tutorials with do this and that, but no one explains what for.

Meanwhile I renamed /var/www/ html/nextcloud/config/config.php to
…html/nextcloud_bak… -> no change.
So, obviousliy, the first config is outdated. I’ll mark it.

Random IPs came up from repeated tries of installation, with he actual IP added to the config. From ncp-config I cannot delete them. Didn’t give me problems by now.

‘datadirectory’ => ‘/media/SSD/ncdata’ is valid. I moved it there.
The first config is outdated.

use **cat** file | **grep** string

I know that one, but what search string.

FIX apache first    

Apache is running fine for other webaccess (webmin, pi hole etc.). But how do I fix this shit up for NC? How to set up the config correctly?

What gives

sudo apachectl -t

This checks the configuration of apache for correctness.

What gives

sudo apachectl -W 

This reads which sites are active

Check that you have valid SSL certificates for your /etc/apache2/sites-available/NC.domain.conf

Also check that nc.domain.conf points to the correct directory

Then

sudo systemctl reload apache2