Distribute Nextcloud across multiple servers fails on NFS

Nextcloud version: 14.0.1
Operating system and version: Ubuntu 16.04, Raspbian 9
Apache or nginx version: Lighttpd lighttpd/1.4.35 (Ubuntu) and lighttpd/1.4.45 (Raspbian)
PHP version: 7.0.30-0+deb9u1 (Raspbian) and 7.0.32-0ubuntu0.16.04.1 (Ubuntu)

The issue you are facing: When trying to run the same Nextcloud instance from different servers mounting via NFS the one which mount the nextcloud folder don’t work and report something like

Data folder isn't valid
Ensure that the ".ocdata" is present in the root of your data folder.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Install an instance on a server (srv1)
  2. Share it via NFS
  3. Mount it on another server (srvn)
  4. Try to access from srvn
  5. Error is reported

NFS export on srv1:


Mount on srvn (fstab):

srv1:/var/www/html/nextcloud /mnt/nextcloud nfs4 _netdev,bg,nofail,rw,relatime,fsc,rsize=65536,wsize=65536 0 0

You don’t try to access the same data folder from different servers at the same time, do you?

Yes, I do… why can’t I do it? However, is there a way to load balance Nextcloud without replicating the data folder?
Thanks in advance

What do you call replication here? You are accessing the same data from different NFS servers, where there’s no locking between them. Also, do you run several distinct databases, one for each NC instance?

Have you searched this forum for load balancing? There is at least one thread, which deals with this in quite detail.

Maybe I haven’t been clear… My goal is to use multiple machines to serve a single nextcloud instance. The nextcloud folder would be the same (or at least the data one), the same for the DB. Regarding the ‘load balancing’ query on the forum I’ve found only a topic in German, which I don’t know. Maybe I need to boost my searching skills, idk.

We use NC distributed environment. You have 1 DB, 1 NFS serving 2 APP servers, and the front-end is HAProxy. This can easily be achieved. Is this what you are looking for? You will have a mount point directly on your linux machine containing the mount for the shared NFS volume.

Yes, this is exactly what I’m trying to achieve. However, I don’t know why, on the slave servers the invalid data folder is shown.

Thanks in advance,

Eugenio Tampieri

Could you paste both the server’s config.php files? Just remove sensitive data where needed.

They all use the same config.php

$CONFIG = array (
  'instanceid' => 'ocws1j898vjr',
  'passwordsalt' => '*',
  'secret' => '*',
  'trusted_domains' => 
  array (
    0 => '*',
    1 => '*',
  'datadirectory' => '/var/www/html/*/data',
  'dbtype' => 'mysql',
  'version' => '',
  'installed' => true,
  'maintenance' => false,
  'loglevel' => 2,
  'user_backend_sql_raw' => 
  array (
    'db_type' => 'mariadb',
    'db_port' => '3306',
    'db_name' => '*',
    'db_user' => '*',
    'db_password' => '*',
    'queries' => 
    array (
      'get_password_hash_for_user' => '*',
      'user_exists' => '*',
      'get_users' => '*',
      'get_display_name' => '*',
      'count_users' => '*',
  'dbname' => '*',
  'dbhost' => '',
  'dbuser' => '*',
  'dbpassword' => '*',
  'overwrite.cli.url' => '*',
  'updater.release.channel' => 'stable',
  'theme' => '',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpsecure' => 'ssl',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '',
    'port' => 6379,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'mail_from_address' => '*',
  'mail_domain' => '*',
  'mail_smtpauth' => 1,
  'mail_smtphost' => '*',
  'mail_smtpport' => '465',
  'mail_smtpname' => '*',
  'mail_smtppassword' => '*',

I think I have found the problem: the mount point is not the same directory… as soon as I get home I’ll check

Cool. Report back or just mark the issue as solved for future users.

Just to know: which algorithm do you use with Haproxy?

Leastconn method. And we do ssl hand-off there as well.

Thanks. I was asking because I had problems with csrf