Nextcloud multi-tenant via data and config (home) separation?

Hello,

I’m running Nextcloud in a dedicated container and all is running well, my cinfig is similar to this now:


  services.nextcloud = {
    enable = true;
    hostName = "first.domain.tld";
    nginx.enable = true;
    https = true;
    maxUploadSize = "512M";
    config = {
      dbtype = "pgsql";
      dbhost = "/tmp";
      dbuser = "nextcloud";
      dbname = "nextcloud";
      dbtableprefix = "first_";
      adminuser = "admin";
      adminpassFile = "/etc/nixos/secrets/first_adminpass";
      extraTrustedDomains = [
        "testfirst.domain.tld"
      ];
    };
  };

I would like to be able to use a multi-tenant Nixos config creating two or more VirtualHosts with the nginx.virtualHosts directive as documented in the nginx.enable option:

Whether to enable nginx virtual host management.
Further nginx configuration can be done by adapting <literal>services.nginx.virtualHosts.&lt;name&gt;</literal>.
See <xref linkend="opt-services.nginx.virtualHosts"/> for further information.

but the linked opt-services.nginx.virtualHosts is missing (link error?).

I’m not able to find an example of virtual host management inside a Nextcloud instance: please have you any suggestion?

I would like to define a multi-tenant Nextcloud instance in a way like this:

   services.nextcloud = {
    enable = true;
    nginx.enable = true;
    nginx.virtualhost."first.domain.tld" = {
      https = true;
      home = /var/lib/nextcloud/first.domain.tld/;
      maxUploadSize = "512M";
      config = {
        dbtype = "pgsql";
        dbhost = "/tmp";
        dbuser = "nextcloud";
        dbname = "nextcloud";
        dbtableprefix = "first_";
        adminuser = "admin";
        adminpassFile = "/etc/nixos/secrets/first_adminpass";
      };
    };
    nginx.virtualhost."second.otherdomain.tld" = {
      https = true;
      home = /var/lib/nextcloud/second.otherdomain.tld/;
      maxUploadSize = "512M";
      config = {
        dbtype = "pgsql";
        dbhost = "/tmp";
        dbuser = "nextcloud";
        dbname = "nextcloud";
        dbtableprefix = "second_";
        adminuser = "admin";
        adminpassFile = "/etc/nixos/secrets/second_adminpass";
      };
    };
  };

Substantially I would like to have different home and different dbpableprefix for each virtualHost so that config, data and other files will be in different homes and database table in a different namespace for each.

I know I can easily define a different container for each virtualHost but I would like to avoid duplication, in particular of the database process (that will become a database cluster) and backup workflow.

Any hint or suggestion will be greatly appreciated.

Thanks. Giovanni.