Skip to main content

3. Editing the config file for nextcloud

Nextcloud's main configuration file is located in its mounted directory. It is located in /config/config.php in the root nextcloud data directory.

Navigating to config file:


  1. We need to first stop the nextcloud container: docker stop nextcloud && docker stop ncdb
  2. First cd into your nextcloud mounted root directory on the host machine. You can alternatively execute into the container and edit the config from there as well.
  3. Once you are in the root directory, enter cd ./config
  4. Then type nano config.php, you should then something similar to below:

Nextcloud-config.php.png

There are three things that we need to edit.

Scroll down until you see trusted domains. You need to add your Docker assigned port number and the server's IP address there, so that you can access the nextcloud interface. Read The Comments Attached Below

?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
   ...
   ...
   ...
  'passwordsalt' => 'LJHLKJHLKJHLSJNDFLJNSDVJNKSJVNKSJBV',
  'secret' => 'LKJGgKHgKLHJgKhgKHgLKHJgjLhgKJhgJHfg',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '10.0.0.31:8080', #Enter your IP address like so, along with the port number
    2 => 'cloud.example.com', #If you plan on accessing this from outside then add your domain
  )

Once that is done, scroll down until you see 'overwriteprotocol' =>. If you can't see this, then simply add 'overwriteprotocol' => 'https', , on the next line add 'default_phone_region' => 'UK', and finally on another line add 'enable_previews' => 'true' there as shown below:

<?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,
      
    ...
    ...
    ...
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '24.0.3.2',
  'overwrite.cli.url' => 'http://localhost',
  'overwriteprotocol' => 'https',   ####ADD THIS HERE  
  'default_phone_region' => 'UK',   ####ADD THIS HERE  
  'enable_previews' => 'true',      ####ADD THIS HERE  

Adding the overwrite_protocol fixes an error on android clients, which prevents the nextcloud app from connecting to the server successfully. The other two lines fix two other minor errors that may occur within the nextcloud instance.

If you plan on using a reverse proxy like Nginx Proxy Manager, then you need to add the IP address of the reverse proxy to the 'trusted_proxies', as shown below:

'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '10.0.0.31:8080',
  	2 => 'cloud.example.com',
  ),
'trusted_proxies' =>
  array (
    0 => '10.0.0.25',
  ),

Once you have entered all that, you have successfully editted the config file. To save it press Ctrl + X,y and Enter. You can now start your nextcloud containers: docker start ncdb && docker start nextcloud.

After the containers have started, head over to http://<ipaddress>:<port> link to access the interface and see if you can login with ncadmin and the password you specificed earlier in the portainer template.

And with that you are done. Your nextcloud instance is setup and ready to go!