In this tutorial you will learn how to run NextCloud and FreeIPA in seperate Docker containers and integrate them to enable a user saved in FreeIPA to log into NextCloud with the same credentials.
This guide includes installing Docker engine on Ubuntu. For other operating systems, Linux platforms, and alternative install methods I'll point you to these guides to
To install Docker on Ubuntu, first uninstall older versions of Docker with the following command:
Next set up the Docker repository:
We can now install the latest version of Docker Engine and containerd
First we'll create the directory which will store server data on the host. Open a new terminal and run
We'll then run the Free-IPA container with the following command (note some options are optional as explained below):
Let's run through each command in turn:
FreeIPA's Docker page provides the following commands to enroll the host to the FreeIPA server running in the container.
Alternatively, you can edit /etc/hosts manually by running
And adding the line
Replacing 127.0.0.1 with the IP address of your host machine.
We can now access the FreeIPA web interface at https://ipa.example.test/ipa/ui/
You can now enter your admin password enterred in the Docker run command (Secret123 in our case) to access the identity management interface.
To setup NextCloud we'll run
We map port 80 of the container to port 9000 of our development machine since FreeIPA is already using our local port 80.
We can now access the NextCloud dashboard at http://localhost:9000
When you have created an admin account as you first log in to NextCloud you can then enable LDAP by going to the apps page and enabling "LDAP user and group backend"
You can access the LDAP configuration panel via the settings under LDAP/AD integration
We can gather some LDAP configuration details from the FreeIPA container:
We'll copy "uid=admin,cn=users,cn=accounts, dc=example,dc=test" as we'll need that for the User DN in NextCloud.
We'll now populate the server tab with configuration details, using Secret123 for the password
The address 172.17.0.1 can be replaced with host.docker.internal on Windows and MacOS as explained in this StackOverflow discussion.
On the Users tab we'll edit the LDAP query to (|(objectclass=*))
On the Login Attributes tab we'll edit the LDAP query to (&(|(objectclass=*))(uid=%uid))
On the Groups tab we'll edit the LDAP query to (|(cn=ipausers))
Next, we'll go to the Advanced tab and ensure the Configuration Active box is checked
Under directory settings we'll set Base User Tree to cn=users,cn=accounts,dc=example,dc=test
And we'll set Base Group Tree to cn=groups,cn=accounts,dc=example,dc=testWe'll also set Group-Member association to uniqueMember
In the Special Attributes section we'll set the Email Field to mail and User Home Folder Naming Rule to cn
You should now see the Configuration OK message
Users can now log into NextCloud using their credentials stored in FreeIPA. You can test this by adding a new user to FreeIPA or logging into NextCloud with your FreeIPA admin credentials (username: admin, password: Secret123).
I ran into a few issues which I'll list here with possible solutions and/or workarounds.
For example
Either of the following two options should work
This error occurs when the ipa-install command is run with the same arguments twice. This can occur if you have removed /var/lib/ipa-data
This happens when you have updated /etc/hosts and your Docker run commands correctly but have not deleted the old configuration information in /var/lib/ipa-data