Persistent "Invalid response: 401" on File Navigation (Docker + Reverse Proxy) - All Configs Checked

Hello everyone,

I’m facing a very persistent “Invalid response: 401” error and have exhausted all standard configuration fixes. I would be very grateful for any help.

The Problem

When navigating through folders in the Files app, I intermittently receive an “Invalid response: 401” error. A hard refresh of the page (F5) temporarily resolves the issue for that specific folder, but the error reappears when navigating to other folders. This has been happening for a while, and it persists through multiple troubleshooting steps.

My Environment

  • Nextcloud Version: 31.0.7.1
  • Installation Method: Docker stack managed with Portainer.
  • Services: nextcloud:latest, mariadb:10.6, redis:alpine, jc21/nginx-proxy-manager:latest
  • Operating System: Ubuntu 24.04.2 LTS (on a Hostinger VPS)
  • PHP Version: 8.3.23

config.php File

My configuration has been corrected multiple times to follow best practices for a reverse proxy and Redis setup.

<?php
$CONFIG = array (
  'instanceid' => 'oc937sy5293b',
  'passwordsalt' => '***REDACTED***',
  'secret' => '***REDACTED***',
  'trusted_domains' => 
  array (
    0 => '31.97.245.34:8080',
    1 => 'geddocsint.duckdns.org',
    2 => 'www.geddocsint.duckdns.org',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '31.0.7.1',
  'overwrite.cli.url' => '[https://geddocsint.duckdns.org](https://geddocsint.duckdns.org)',
  'overwriteprotocol' => 'https',
  'overwritehost' => 'geddocsint.duckdns.org',
  'trusted_proxies' => 
  array (
    0 => '172.20.0.2',
  ),
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '***REDACTED***',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'installed' => true,
  'default_phone_region' => 'BR',
  'maintenance' => false,
  'loglevel' => 2,
  'maintenance_window_start' => 3,
  'dbtxnlevel' => 'READ-COMMITTED',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => [
    'host' => 'redis',
    'port' => 6379,
  ],
  'session_handler' => 'redis',
  'session_save_path' => 'tcp://redis:6379',
  'session_lifetime' => 604800,
  'htaccess.RewriteBase' => '/',
);