Problem with EC2 and S3 arquitecture

Nextcloud version : 23.0.2.1
Operating system and version : Ubuntu 18.04 (bionic)
Apache version : nginx/1.14.0
PHP version : 8.0.16

We got running a dokku app with the docker image through: “sudo docker pull nextcloud:latest”. This is done in a dokku enviroment in an EC2 amazon machine.

Our problem is that we can upload files up to certain size, but after certain size, it crashes (it seems that it depends on the time the file takes to be uploaded).

The nextcloud log error line:

{"reqId":"rNaD6aQVUX1sO6l6QgBO","level":2,"time":"2022-02-24T16:59:46+00:00","remoteAddr":"172.17.0.1","user":"--","app":"no app in context","method":"GET","url":"/index.php","message":"Host 172.31.27.197 was not connected to because it violates local access rules","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36","version":"23.0.2.1"}

We also think it might have to do with amazon internal routing, because it shouldn’t be a local

We already updated the config with: ‘allow_local_remote_servers’ => true

We setup the config of the nextcloud app to use S3 bucket machine as database. Here’s the config.php:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'objectstore' =>
  array (
    'class' => '\\OC\\Files\\ObjectStore\\S3',
    'arguments' =>
    array (
      'bucket' => 'mycloud-test-nextcloud',
      'key' => 'XXXXX',
      'secret' => 'XXXXX',
      'region' => 'eu-central-1',
      'hostname' => 's3.amazonaws.com',
      'port' => '',
      'objectPrefix' => 'urn:oid:',
      'autocreate' => false,
      'use_ssl' => false,
      'use_path_style' => false,
      'legacy_auth' => false,
    ),
  ),
  'instanceid' => 'ocy1kprsrcg9',
  'passwordsalt' => 'XXXXX',
  'secret' => 'XXXXXX',
  'trusted_domains' =>
  array (
    0 => 'cloud--temp.yuust.com'
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '23.0.2.1',
  'overwrite.cli.url' => 'http://cloud--temp.yuust.com',
  'dbname' => 'cloud--temp',
  'dbhost' => 'XXXXXXX',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'admin_example',
  'dbpassword' => 'XXXXXXX',
  'installed' => true,
  'allow_local_remote_servers' => true
);