One database for multiple NC instance

Hi,

I have one mysql database where my users are stored. All users are in a specific group. I also have many nextcloud instances on the same server.
Currently, all my instances with “user_sql” backend automatically generate all users I have in my database.
I’d like to use my users database for all instances but without having all accounts on all instances.

Here an example of my needs:

  • I have a first instance “nc.example1.com” and a second “nc.example2.com”.
  • I have users bob in the group “example1”, and mike in the group “example2”.
  • Instance “nc.example1.com” only allow users in the group “example1” (bob), and instance “nc.example2.com” only allow users in the group “example2” (mike).

Is its possible? Do you know the way to do that please?

you should not point multiple NC instances to the same database. each NC should use a dedicated database (but may share same DB server if required). then users are automatically separated and isolated from each other.

@Thom1
The problem is that for every user is not only username and password but also a lot of other user information stored. For centralized user management, LDAP or active directory is used nowadays. You can connect your Nextclouds to one central user management (LDAP, Active Directory). But there are user, password and e.g. a few groups but not all user information from your Nextcloud included.

Read this. This is the normal way also with multiple Nextclouds:
User authentication with LDAP

Every Nextcloud does not need an own database server and also not an own database. Every Nextcloud only needs an own database “under structure”.

Database configuration
(Standard is MariaDB)

part of config/config.php:

  "dbtype"        => "mysql",
  "dbname"        => "nextcloud",
  "dbuser"        => "username",
  "dbpassword"    => "password",
  "dbhost"        => "localhost",
  "dbtableprefix" => "oc_",

second nextcloud same MariaDB on same server e.g.:

  "dbtype"        => "mysql",
  "dbname"        => "nextcloud2",
  "dbuser"        => "username2",
  "dbpassword"    => "password2",
  "dbhost"        => "localhost",
  "dbtableprefix" => "oc_",

Hi,

Thanks for your answers. I’m sorry, I didn’t explain correctly, and my english is not very good.

Every nextcloud instance has its own database, of course. I also store my email account (for postfix/dovecot) on a dedicated mysql database. I always use “user_external” app on nextcloud with imap authentification to “link” an email account to a nextcloud account. This way every user has only one account for mail and nextcloud.

But “user_external” app seems abandonned so I’m trying to directly use my email database with “user_sql” app.

I write a better example:

  1. I have a database for my email account (postfix/dovecot) called “mail”
  2. I have a first instance “nc.example1.com” using a database called “nc1”
  3. I have a second instance “nc.example2.com” using a database called “nc2”
  4. In my mail database, I have a row “group” to know if a user should be able to login to “nc.example1.com” or “nc.example2.com” instance.

What’s happening now? “user_sql” app works fine because I can login to nextcloud using a mail account.

So what’s my issue? Since I setup “user_sql” app on nextcloud, all my email account have a nextcloud account on every instances.

What do I want? I’d like my users to be able to login only on the instance depending on the “group” row in my mail database.

I hope my explaination is better.

Thanks again :slight_smile:

I think the app External user authentication has got a lot of possibilities.

Please read Github - user_external and Github - user_sql .

Which part of software do you use?
Can you post a screenshot of your actual configuration?
Perhaps you can write an issue at one of the both above links.

I used “External user authentification” (user_external) since many years and I’m happy with it. But the app seems abandonned. That’s why I want to use “user_sql” now.

Here the screenshot of my user_sql config.
nextcloud-user_sql

I will write a request on user_sql github. Thanks. :slight_smile:

Hi,

I open an issue on github.
Waiting a real solution, I have a workaround. I made a cron task which disable unwanted users on nextcloud and delete their empty data folder.

Thanks for you help! :wink:

1 Like