iOS and desktop apps don't work, web interface works fine

Nextcloud version (eg, 20.0.5): Nextcloud Hub II (23.0.3)
Operating system and version (eg, Ubuntu 20.04): Linux homeserv 5.10.0-12-amd64 #1 SMP Debian 5.10.103-1 (2022-03-07) x86_64 GNU/Linux
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.53 (Debian)
PHP version (eg, 7.4): PHP 7.4.28

The issue you are facing:
Not able to use iOS or desktop apps. Every time I log in on either of those, I get an error, that password re-entry is required. Username and passowrd are OK for sure. Web interface works as expected.
If I comment out the SetHandler directive in apache config, it works fine, but then I loose the fcgi engine (I guess… I’m not good with this staff, just playing around, seing what things does, trying to understand, just not sure, what is this about and how to work around it, or what to change). Apache config is appended at the end. If you need to see any more logs or config files, let me know which one please.
Also, in the NC error log I noticed, that when I enter wrong password for the user, the IP recorded is the IP of the router on my LAN. NC is ran on a computer with different IP and request came from iphone with yet another IP. That looks a bit strange to me…

Thanks for any help guys…

The output of your Nextcloud log in Admin > Logging:

Warning	no app in context	Login failed: esso (Remote IP: 192.168.24.1)		2022-04-16T16:25:18+0200
Warning	dav	GuzzleHttp\Exception\ClientException: Client error: `GET https://mail.diplomat-dental.com/ical/stanislav_sladecek@diplomat-dental.com/Calendar` resulted in a `401 Unauthorized` response: <HTML><HEAD><TITLE>Error 401 Unauthorized</TITLE></HEAD><BODY><H1>401 Unauthorized</H1>You are not authorized to access (truncated...)		2022-04-13T09:34:20+0200
Warning	dav	GuzzleHttp\Exception\ClientException: Client error: `GET https://mail.diplomat-dental.com/ical/stanislav_sladecek@diplomat-dental.com/Calendar` resulted in a `401 Unauthorized` response: <HTML><HEAD><TITLE>Error 401 Unauthorized</TITLE></HEAD><BODY><H1>401 Unauthorized</H1>You are not authorized to access (truncated...)		2022-04-13T07:56:30+0200
Warning	no app in context	Login failed: esso (Remote IP: 192.168.24.1)		2022-04-11T14:39:31+0200
Warning	no app in context	OCP\Files\StorageAuthException: Storage unauthorized. Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-11T14:29:53+0200
Warning	no app in context	External storage not available: Storage unauthorized. Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-11T14:29:53+0200
Error	no app in context	Icewind\SMB\Exception\ConnectException: Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-11T14:29:53+0200
Warning	no app in context	OCP\Files\StorageAuthException: Storage unauthorized. Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-11T14:29:48+0200
Warning	no app in context	External storage not available: Storage unauthorized. Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-11T14:29:48+0200
Error	no app in context	Icewind\SMB\Exception\ConnectException: Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-11T14:29:48+0200
Warning	no app in context	OCP\Files\StorageAuthException: Storage unauthorized. Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-11T14:29:46+0200
Warning	no app in context	External storage not available: Storage unauthorized. Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		

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

<?php
$CONFIG = array (
  'instanceid' => '#removed',
  'passwordsalt' => '#removed',
  'secret' => '#removed',
  'trusted_domains' =>
  array (
    0 => 'homeserv',
    1 => '#removed',
  ),
  'datadirectory' => '/var/www/cloud-data',
  'dbtype' => 'mysql',
  'version' => '23.0.3.2',
  'overwrite.cli.url' => 'https://homeserv/cloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '#removed',
  'installed' => true,
  'app_install_overwrite' =>
  array (
    0 => 'printer',
  ),
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'default_phone_region' => 'SK',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

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

109.237.103.123 - - [16/Apr/2022:14:12:11 +0200] "GET /public/aws/credentials HTTP/1.1" 301 620 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
109.237.103.123 - - [16/Apr/2022:14:12:11 +0200] "POST /public/aws/credentials HTTP/1.1" 301 620 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
109.237.103.123 - - [16/Apr/2022:14:12:11 +0200] "GET /public/.aws HTTP/1.1" 301 598 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
109.237.103.123 - - [16/Apr/2022:14:12:12 +0200] "POST /public/.aws HTTP/1.1" 301 598 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
192.241.225.78 - - [16/Apr/2022:14:14:32 +0200] "GET / HTTP/1.1" 301 520 "-" "Mozilla/5.0 zgrab/0.x"
178.68.47.163 - - [16/Apr/2022:14:16:10 +0200] "GET / HTTP/1.1" 301 520 "-" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"
192.241.214.35 - - [16/Apr/2022:15:05:16 +0200] "GET / HTTP/1.1" 301 520 "-" "Mozilla/5.0 zgrab/0.x"
64.62.197.122 - - [16/Apr/2022:15:57:38 +0200] "GET / HTTP/1.1" 301 520 "-" "-"
35.233.62.116 - - [16/Apr/2022:16:01:13 +0200] "GET / HTTP/1.1" 301 576 "-" "python-requests/2.27.1"
80.234.21.249 - - [16/Apr/2022:16:01:28 +0200] "GET / HTTP/1.1" 301 520 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
104.206.128.2 - - [16/Apr/2022:16:03:56 +0200] "GET / HTTP/1.0" 301 543 "-" "https://gdnplus.com:Gather Analyze Provide."
103.178.237.132 - - [16/Apr/2022:16:16:36 +0200] "GET / HTTP/1.1" 301 520 "-" "-"
192.241.225.168 - - [16/Apr/2022:16:17:03 +0200] "GET / HTTP/1.1" 301 520 "-" "Mozilla/5.0 zgrab/0.x"
::1 - - [16/Apr/2022:16:20:29 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:20:44 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:24:25 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:24:26 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:12 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:13 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:14 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:15 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:16 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:26 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:27 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:45 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:46 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:47 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:25:48 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:26:21 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:26:23 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
61.32.105.148 - - [16/Apr/2022:16:28:50 +0200] "GET / HTTP/1.0" 301 576 "-" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"
::1 - - [16/Apr/2022:16:39:25 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:39:26 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:39:27 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:39:28 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:39:29 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:39:41 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:39:49 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:12 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:13 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:14 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:15 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:16 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:24 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:26 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:50 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"
::1 - - [16/Apr/2022:16:40:51 +0200] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) mod_fcgid/2.3.9 OpenSSL/1.1.1n (internal dummy connection)"

Apache error log:


2022-04-02T16:05:00+0200
Error	no app in context	Icewind\SMB\Exception\ConnectException: Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-02T15:40:31+0200
Error	no app in context	Icewind\SMB\Exception\ConnectionRefusedException: 		2022-04-02T15:34:06+0200
Error	no app in context	Icewind\SMB\Exception\ConnectException: Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-01T14:35:10+0200
Error	no app in context	Icewind\SMB\Exception\ConnectException: Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-01T14:35:09+0200
Error	no app in context	Icewind\SMB\Exception\ConnectException: Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-01T14:23:07+0200
Error	no app in context	Icewind\SMB\Exception\ConnectException: Unknown error (gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied gencache_init: Failed to create directory: /var/www/.cache/samba - Permission denied)		2022-04-01T14:23:06+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve externalMountProvider! Class externalMountProvider does not exist		2022-04-01T14:18:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve OCA\Files_Versions\Versions\IVersionManager! Class can not be instantiated		2022-04-01T14:18:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve trashManager! Class trashManager does not exist		2022-04-01T14:18:29+0200
Error	index	RedisException: No such file or directory		2022-04-01T14:18:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve externalMountProvider! Class externalMountProvider does not exist		2022-04-01T14:17:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve OCA\Files_Versions\Versions\IVersionManager! Class can not be instantiated		2022-04-01T14:17:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve trashManager! Class trashManager does not exist		2022-04-01T14:17:29+0200
Error	index	RedisException: No such file or directory		2022-04-01T14:17:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve externalMountProvider! Class externalMountProvider does not exist		2022-04-01T14:12:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve OCA\Files_Versions\Versions\IVersionManager! Class can not be instantiated		2022-04-01T14:12:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve trashManager! Class trashManager does not exist		2022-04-01T14:12:29+0200
Error	index	RedisException: No such file or directory		2022-04-01T14:12:29+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve externalMountProvider! Class externalMountProvider does not exist		2022-04-01T14:10:40+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve OCA\Files_Versions\Versions\IVersionManager! Class can not be instantiated		2022-04-01T14:10:40+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve trashManager! Class trashManager does not exist		2022-04-01T14:10:40+0200
Error	index	RedisException: No such file or directory		2022-04-01T14:10:40+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve externalMountProvider! Class externalMountProvider does not exist		2022-04-01T14:10:38+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve OCA\Files_Versions\Versions\IVersionManager! Class can not be instantiated		2022-04-01T14:10:38+0200
Error	no app in context	OCP\AppFramework\QueryException: Could not resolve trashManager! Class trashManager does not exist		2022-04-01T14:10:38+0200
Error	index	RedisException: No such file or directory		2022-04-01T14:10:38+0200

Apache config:

<VirtualHost *:80>
        ServerName #removed.ddns.net

        ServerAdmin webmaster@localhost
        Redirect permanent / https://#removed.ddns.net/

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

</VirtualHost>

<VirtualHost _default_:443>
        ServerName #removed.ddns.net
        DocumentRoot /var/www
            <FilesMatch \.php$>
                SetHandler "proxy:unix:/var/run/php/php7.4-fpm.sock|fcgi://localhost/"
            </FilesMatch>
            <IfModule mod_headers.c>
                Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
            </IfModule>
        Redirect 301 /.well-known/carddav /cloud/remote.php/dav
        Redirect 301 /.well-known/caldav /cloud/remote.php/dav
        Redirect 301 /.well-known/webfinger /cloud/index.php/.well-known/webfinger
        Redirect 301 /.well-known/nodeinfo /cloud/index.php/.well-known/nodeinfo
        SSLEngine On
        SSLCertificateFile /etc/letsencrypt/live/#removed.ddns.net/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/#removed.ddns.net/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Do you use external smb storage? What about these permissions, are they accessible for the www-data user?

Hi. Thanks for answer. I’m aware of the permissions issue for external storage mount, I will solve that later, I’m sure it has nothing to do with the described issue above.

Anyway, maybe a hint would be useful. That means, how does rendering folders works in web browser versus ios/desktop app? That might point me in the right direction…