Internal Server Error after install with docker-compose and S3 primary storage

Hello,

I am new to nextcloud and I am working to perform a clean, secured, install on a amazon EC2 server from docker and docker-compose, with an amazon S3 bucket as primary external storage.

Yesterday I managed to install Nextcloud from docker-compose without external storage nor ssl encryption. I could use it normally.
Today, I tried a new install with a primary external storage. I :

  1. cleaned the docker volumes
  2. run sudo docker-compose up db to create the database
  3. run sudo docker-compose up to install nextcloud
  4. updated the config.php file generated during the nextcloud install with the info regarding the s3 bucket
  5. relaunched docker-compose up
  6. accessed nextcloud
  7. logged in
  8. received an Internal Server Error

Please find below my docker-compose.yml file
version: ‘3’

services:

  nextcloud:
    image: nextcloud
    container_name: nextcloud
    ports:
      - 80:80
      - 443:443
    links:
      - db
    volumes:
      - ./apps:/var/www/html/apps
      - ./config:/var/www/html/config
      - ./storage:/var/www/html/data
    restart: always
    
  db:
    image: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    container_name: db
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=******
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=******
    restart: always

And my config.php file after adding the external primary storage :

<?php
$CONFIG = array (
  'passwordsalt' => 'F0NH9SobnkK/NlzcrYVfK7min1IkYP',
  'secret' => 'QGhxRlXGneEBKcTXcrHCGKGLnNCdcmmdknWf3O/3LFd5iJAC',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '****',
    2 => '****',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '15.0.2.0',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => '',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '****',
  'installed' => true,
  'objectstore' =>
  array (
    'class' => 'OC\\Files\\ObjectStore\\S3',
    'arguments' =>
    array (
      'bucket' => 'nextclouds3storage',
      'autocreate' => true,
      'key' => '****',
      'secret' => '****',
      'use_ssl' => true,
      'region' => 'eu-west-3',
    ),
  ),
  'instanceid' => 'oc5pvrh3m5r2',
);

Am I missing something ?
Does setting AWS S3 as a primary external storage requires ssl encryption, if so why ? (as the communication between ec2 and s3 should already be encrypted) Is there some incompatibility between setting AWS S3 as external storage and docker ?

EDIT: For information, the S3 bucket is correctly created.

the internal error was?
in the logs you find what?

(to my knowledge you can access s3 via http. or?)

1 Like

Thank, this helpded me !
The logs are

Logs

{
“reqId”:“gVmaH1HH1UzfONImS4uV”,
“level”:3,
“time”:“2019-02-07T15:51:41+00:00”,
“remoteAddr”:“165.225.76.150”,
“user”:“admin”,
“app”:“index”,
“method”:“GET”,
“url”:"/index.php/apps/files/",
“message”:{
“Exception”:“OCP\Files\NotFoundException”,
“Message”:"",
“Code”:0,
“Trace”:[
{
“file”:"/var/www/html/apps/files/lib/Controller/ViewController.php",
“line”:128,
“function”:“getStorageInfo”,
“class”:“OC_Helper”,
“type”:"::",
“args”:[
“/”,
false
]
},
{
“file”:"/var/www/html/apps/files/lib/Controller/ViewController.php",
“line”:157,
“function”:“getStorageInfo”,
“class”:“OCA\Files\Controller\ViewController”,
“type”:"->",
“args”:[
]
},
{
“file”:"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
“line”:166,
“function”:“index”,
“class”:“OCA\Files\Controller\ViewController”,
“type”:"->",
“args”:[
“”,
“”,
null,
false
]
},
{
“file”:"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
“line”:99,
“function”:“executeController”,
“class”:“OC\AppFramework\Http\Dispatcher”,
“type”:"->",
“args”:[
{
class”:“OCA\Files\Controller\ViewController”
},
“index”
]
},
{
“file”:"/var/www/html/lib/private/AppFramework/App.php",
“line”:118,
“function”:“dispatch”,
“class”:“OC\AppFramework\Http\Dispatcher”,
“type”:"->",
“args”:[
{
class”:“OCA\Files\Controller\ViewController”
},
“index”
]
},
{
“file”:"/var/www/html/lib/private/AppFramework/Routing/RouteActionHandler.php",
“line”:47,
“function”:“main”,
“class”:“OC\AppFramework\App”,
“type”:"::",
“args”:[
“ViewController”,
“index”,
{
class”:“OC\AppFramework\DependencyInjection\DIContainer”
},
{
“_route”:“files.view.index”
}
]
},
{
“function”:"__invoke",
“class”:“OC\AppFramework\Routing\RouteActionHandler”,
“type”:"->",
“args”:[
{
“_route”:“files.view.index”
}
]
},
{
“file”:"/var/www/html/lib/private/Route/Router.php",
“line”:297,
“function”:“call_user_func”,
“args”:[
{
class”:“OC\AppFramework\Routing\RouteActionHandler”
},
{
“_route”:“files.view.index”
}
]
},
{
“file”:"/var/www/html/lib/base.php",
“line”:987,
“function”:“match”,
“class”:“OC\Route\Router”,
“type”:"->",
“args”:[
“/apps/files/”
]
},
{
“file”:"/var/www/html/index.php",
“line”:42,
“function”:“handleRequest”,
“class”:“OC”,
“type”:"::",
“args”:[
]
}
],
“File”:"/var/www/html/lib/private/legacy/helper.php",
“Line”:514,
“CustomMessage”:"–"
},
“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Safari/537.36”,
“version”:“15.0.2.0”
}

Looking into this forum for similar issues, I found this issue #98. As the cause could be user rights, I made sure the user www-data was the owner of my storage folder.
Then I cleaned everything again, reinstalled. After reinstallation I got a trusted domain name error, so I edited the config.php to edit my domain name and make S3 my default storage. aaaand… I got the same error.
To make sure the problem was related to the S3 config, I removed that part from the config.php file, and retried : it worked.

At this point, I was quite sure the problem was with the S3 configuration. So I edited (again) the config.php file to put the the ‘objectstore’ config back. And surprise, it worked. After several restart, it is still working fine.
I am quite happy with this, but I would like to understand what happened. Did nextcloud needed to be accessed at least once without external storage before the objectstore config could work ?

If you want to investigate this further you may want to look at

putting this in the userdata field of a spot instance saves a lot of time to setup a test nextcloud. :wink:

I’ll try to put here an option to set a s3 bucket as primary storage. stay tuned.

@Allirion what i found: you get the internal error messages at this point because nextcloud doesn’t migrate the user files and folders. so at step 4 you should delete the default admin user and recreate it or after step 5 create a second admin user.

1 Like