Nextcloud redirects to localhost:881

So I installed the linuxserver/nextcloud image as well as the linuxserver/mariadb image and set them up.

Now this works fine as long as I am in my local network and access my home server via his internal IP-Adress but as soon as I try to connect to it via my domain it redirects me to localhost:881.

I have setup a nginx proxy to redirect to


EDIT: Note that I forwarded the docker Port from 444 external to 443 internal.

please review reverse proxy settings. Likely you misconfigured some overwrite parameter. use search the issue was discussed often already.

So I’ve reset my complete installation and now am no longer getting a redirect to localhost:881.

Now I am getting a 504 Gateway Time-out

I edited my config.php to the following:

<?php
$CONFIG = array (
  'datadirectory' => '/data',
  'instanceid' => 'ocljvk3tyljh',
  'passwordsalt' => '<redacted>',
  'secret' => '<redacted>',
  'trusted_domains' =>
  array (
    0 => '192.168.50.221:444',
    1 => 'next.<mydomain>.com',
    2 => '<mydomain>.com',
  ),
  'trusted_proxies' => ['<myRouterIP>'],
  'dbtype' => 'mysql',
  'version' => '29.0.4.1',
  'overwriteprotocol' => 'https',
  'overwrite.cli.url' => 'https://next.<mydomain>.com',
  'dbname' => 'nextcloud',
  'dbhost' => '192.168.50.221:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '<myPassword>.',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\APCu',
  'upgrade.disable-web' => true,
);'

I am still running the nginx Proxy as above with the added advanced settings:

location /.well-known/carddav {
    return 301 $scheme://$host/remote.php/dav;
}

location /.well-known/caldav {
    return 301 $scheme://$host/remote.php/dav;
}