Nextcloud: Difference between revisions
Automatically add missing indices |
→Change default listening port: switch localhost to yourHostName to warn that they should use the configured nextcloud hostname |
||
(28 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
[https://nextcloud.com/ {{PAGENAME}}] ([[wikipedia:en:{{PAGENAME}}]]) is a self-hosted web groupware and cloud software, offering collaboration on files, managing calendar events, contacts and tasks. | [https://nextcloud.com/ {{PAGENAME}}] ([[wikipedia:en:{{PAGENAME}}]]) is a self-hosted web groupware and cloud software, offering collaboration on files, managing calendar events, contacts and tasks. | ||
This article extends the documentation in the [https://nixos.org/manual/nixos/stable/#module-services-nextcloud NixOS manual]. | |||
A minimal example to get | == Setup == | ||
A minimal example to get the latest Nextcloud version (for your specific NixOS release) running on localhost should look like this, replacing <code>PWD</code> with a 10+ char password that meets [https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/user_password_policy.html Nextcloud's default password policy]. | |||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
Line 9: | Line 11: | ||
services.nextcloud = { | services.nextcloud = { | ||
enable = true; | enable = true; | ||
hostName = "localhost"; | hostName = "localhost"; | ||
config.adminpassFile = "/etc/nextcloud-admin-pass"; | config.adminpassFile = "/etc/nextcloud-admin-pass"; | ||
Line 15: | Line 16: | ||
</nowiki>}} | </nowiki>}} | ||
After that you will be able to login into your Nextcloud instance at http://localhost with user <code>root</code> and password <code>PWD</code> as configured above. | After that you will be able to login into your Nextcloud instance at <code><nowiki>http://localhost</nowiki></code> with user <code>root</code> and password <code>PWD</code> as configured above. | ||
== Configuration == | == Configuration == | ||
Line 23: | Line 24: | ||
=== Apps === | === Apps === | ||
[https://github.com/NixOS/nixpkgs/blob/ | [https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/nextcloud/packages/nextcloud-apps.json Some apps] which are already packaged on NixOS can be installed directly with the following example configuration | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
Line 29: | Line 30: | ||
enable = true; | enable = true; | ||
[...] | [...] | ||
# Instead of using pkgs.nextcloud29Packages.apps or similar, | |||
# Instead of using pkgs. | # we'll reference the package version specified in services.nextcloud.package | ||
# we'll reference the package version specified | |||
extraApps = { | extraApps = { | ||
inherit (config.services.nextcloud.package.packages.apps) news contacts calendar tasks; | inherit (config.services.nextcloud.package.packages.apps) news contacts calendar tasks; | ||
Line 50: | Line 50: | ||
inherit (config.services.nextcloud.package.packages.apps) news contacts calendar tasks; | inherit (config.services.nextcloud.package.packages.apps) news contacts calendar tasks; | ||
memories = pkgs.fetchNextcloudApp { | memories = pkgs.fetchNextcloudApp { | ||
url = "https://github.com/pulsejet/memories/releases/download/v6.2.2/memories.tar.gz"; | |||
hash = "sha256-Xr1SRSmXo2r8yOGuoMyoXhD0oPVm/0/ISHlmNZpJYsg="; | |||
license = "agpl3Only"; | |||
}; | }; | ||
Line 90: | Line 90: | ||
Alternatively apps can be manually installed via the app store integrated in your Nextcloud instance by navigating in the profile menu to the site "Apps". | Alternatively apps can be manually installed via the app store integrated in your Nextcloud instance by navigating in the profile menu to the site "Apps". | ||
=== | === TLS === | ||
If you would like to setup Nextcloud with Let's Encrypt TLS certificates (or certs from any other certificate authority) make sure to set <code>services.nextcloud.https = true;</code> and to enable it in the nginx- | If you would like to setup Nextcloud with Let's Encrypt TLS certificates (or certs from any other certificate authority) make sure to set <code>services.nextcloud.https = true;</code> and to enable it in the nginx-VirtualHost. | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
Line 98: | Line 98: | ||
enable = true; | enable = true; | ||
[...] | [...] | ||
hostName = "example.org"; | hostName = "nextcloud.example.org"; | ||
https = true; | https = true; | ||
}; | }; | ||
Line 206: | Line 206: | ||
=== Secrets management === | === Secrets management === | ||
Do not suply passwords, hashes or keys via | Do not suply passwords, hashes or keys via the settings option, since they will be copied into the world-readable Nix store. Instead reference a JSON file containing secrets using the <code>secretFile</code> option. | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> | ||
Line 227: | Line 227: | ||
Consider using a [[Comparison of secret managing schemes|secret management tool]] instead of referencing an unencrypted local secrets file. | Consider using a [[Comparison of secret managing schemes|secret management tool]] instead of referencing an unencrypted local secrets file. | ||
=== Dynamic configuration === | |||
Unfortunately, some options can only be set 'interactively' in the database (either through the nextcloud-occ command line tool or the web UI), and not via the configuration file. One way to manage them "semi-declaratively" is to register a systemd script to reset the options on each redeploy: | |||
<syntaxHighlight lang="nix"> | |||
systemd.services.nextcloud-custom-config = { | |||
path = [ | |||
config.services.nextcloud.occ | |||
]; | |||
script = '' | |||
nextcloud-occ theming:config name "My Cloud" | |||
nextcloud-occ theming:config url "https://cloud.mine.com"; | |||
nextcloud-occ theming:config privacyUrl "https://www.mine.com/privacy"; | |||
nextcloud-occ theming:config color "#3253a5"; | |||
nextcloud-occ theming:config logo ${./logo.png} | |||
''; | |||
after = [ "nextcloud-setup.service" ]; | |||
wantedBy = [ "multi-user.target" ]; | |||
}; | |||
</syntaxHighlight>Of course this is not ideal: changes through the web interface or occ client are still possible but will be overwritten the next redeploy, and removing a line from the script will not remove it from the configuration. | |||
== Maintenance == | == Maintenance == | ||
Line 245: | Line 265: | ||
You can access the mysql database, for backup/restore, etc. like this: | You can access the mysql database, for backup/restore, etc. like this: | ||
<code>sudo | <code>sudo -u nextcloud -- mysql -u nextcloud <options></code> | ||
No password is required. | No password is required. | ||
== Clients == | == Clients == | ||
Line 270: | Line 273: | ||
=== Nextcloudcmd === | === Nextcloudcmd === | ||
''nextcloudcmd'' is a terminal client performing only a single sync run and then exits. The following example command will synchronize the local folder <code>/home/myuser/music</code> with the remote folder <code>/music</code> of the Nextcloud server <code>https://nextcloud.example.org</code>. | ''nextcloudcmd'' is a terminal client performing only a single sync run and then exits. The following example command will synchronize the local folder <code>/home/myuser/music</code> with the remote folder <code>/music</code> of the Nextcloud server <code><nowiki>https://nextcloud.example.org</nowiki></code>. | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
Line 282: | Line 285: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
home-manager.users.myuser = { | home-manager.users.myuser = { | ||
systemd.user = { | systemd.user = { | ||
services.nextcloud-autosync = { | services.nextcloud-autosync = { | ||
Line 311: | Line 308: | ||
startServices = true; | startServices = true; | ||
}; | }; | ||
}; | }; | ||
</nowiki>}} | </nowiki>}} | ||
Line 320: | Line 316: | ||
"nextcloud-client" is a nextcloud themed desktop client. | "nextcloud-client" is a nextcloud themed desktop client. | ||
It requires a keyring to store its login token. Without an active keyring, the user will be asked | It requires a keyring to store its login token. Without an active keyring, the user will be asked to login on every application startup. | ||
== Tips and tricks == | == Tips and tricks == | ||
Line 329: | Line 325: | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
services.nginx.virtualHosts." | services.nginx.virtualHosts."yourHostName".listen = [ { addr = "127.0.0.1"; port = 8080; } ]; | ||
</nowiki>}} | </nowiki>}} | ||
=== Enable HEIC image preview === | === Enable HEIC image preview === | ||
HEIC image preview needs to be explicitly enabled. This is done by adjusting the <code>enabledPreviewProviders</code> option. Beside the default list of supported formats, add an additional line <code>"OC\\Preview\\HEIC"</code> for HEIC image support. | HEIC image preview needs to be explicitly enabled. This is done by adjusting the <code>enabledPreviewProviders</code> option. Beside the default list of supported formats, add an additional line <code>"OC\\Preview\\HEIC"</code> for HEIC image support. See also [https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#enabledpreviewproviders this list of preview providers] for additional file types. | ||
{{file|/etc/nixos/configuration.nix|nix|<nowiki> | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
services.nextcloud = { | services.nextcloud = { | ||
settings.enabledPreviewProviders = [ | |||
"OC\\Preview\\BMP" | "OC\\Preview\\BMP" | ||
"OC\\Preview\\GIF" | "OC\\Preview\\GIF" | ||
Line 354: | Line 350: | ||
</nowiki>}} | </nowiki>}} | ||
=== Run | === Run Nextcloud in a sub-directory === | ||
Say, you don't want to run nextcloud at <code>your.site/</code> but in a sub-directory <code>your.site/nextcloud/</code>. To do so, we are going to add more configurations to nextcloud and to nginx to [[Nginx#TLS_reverse_proxy|make]] it a [https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ reverse-proxy]. | Say, you don't want to run nextcloud at <code>your.site/</code> but in a sub-directory <code>your.site/nextcloud/</code>. To do so, we are going to add more configurations to nextcloud and to nginx to [[Nginx#TLS_reverse_proxy|make]] it a [https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/ reverse-proxy]. | ||
Line 424: | Line 420: | ||
</nowiki>}} | </nowiki>}} | ||
Note: If you have | Note: If you have TLS (https) enabled, make sure nginx forwards to the correct port and nextcloud overwrites for the correct protocol. | ||
=== Use Caddy as webserver === | === Use Caddy as webserver === | ||
Line 479: | Line 475: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== App specific configuration == | |||
=== Whiteboard === | |||
The [https://github.com/nextcloud/whiteboard Whiteboard app] requires a running backend server which is also packaged in NixOS.<syntaxhighlight lang="nix"> | |||
environment.etc."nextcloud-whiteboard-secret".text = '' | |||
JWT_SECRET_KEY=test123 | |||
''; | |||
services.nextcloud-whiteboard-server = { | |||
enable = true; | |||
settings.NEXTCLOUD_URL = "http://localhost"; | |||
secrets = [ /etc/nextcloud-whiteboard-secret ]; | |||
}; | |||
</syntaxhighlight>After applying the configuration configure the Nextcloud app to use it<syntaxhighlight lang="bash"> | |||
nextcloud-occ config:app:set whiteboard collabBackendUrl --value="http://localhost:3002" | |||
nextcloud-occ config:app:set whiteboard jwt_secret_key --value="test123" | |||
</syntaxhighlight> | |||
=== NextCloud Office === | |||
The [https://nextcloud.com/office/ NextCloud Office app] provides a Google Docs like online office suite integrated into NextCloud. For this to work it requires a document server that provides the editing functionality as a [[wikipedia:Web_Application_Open_Platform_Interface|WOPI]] client. | |||
The main options to use as WOPI client are [https://www.onlyoffice.com/ ONLYOFFICE] and [https://www.collaboraonline.com Collabora Online]. Although the documentation makes it look like Collabora Online is the only option, any document server with WOPI capabilities can be used. | |||
To enable the NextCloud Office app, add the following to your configuration:<syntaxhighlight lang="nixos"> | |||
services.nextcloud = { | |||
enable = true; | |||
extraApps = { | |||
inherit (config.services.nextcloud.package.packages.apps) richdocuments; | |||
}; | |||
} | |||
</syntaxhighlight> | |||
=== ONLYOFFICE === | |||
You need to install both a document server and the [https://apps.nextcloud.com/apps/onlyoffice ONLYOFFICE Nextcloud plug-in]. There are several ways to install onlyoffice: | |||
===== services.onlyoffice ===== | |||
Due to https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/931 you need to apply the workaround from https://github.com/NixOS/nixpkgs/pull/338794. | |||
Then point the app to the document server from within the Nextcloud UI ("Administration Settings" -> Administration -> ONLYOFFICE), and make sure the 'services.onlyoffice.jwtSecretFile points to a file containing the same key as entered in the configuration of the Nextcloud app. | |||
===== the documentserver_community Nextcloud app ===== | |||
(not tested) | |||
===== in a docker/podman container ===== | |||
(not tested) | |||
==== Collabora Online ==== | |||
Collabora comes in two flavors: | |||
* Collabora Online For Business / For Enterprise | |||
* Collabora Online Development Edition (aka CODE) | |||
As the name indicates the former two require a license, while the latter is free for evaluation and personal use. | |||
For easy deployment, there's the [https://apps.nextcloud.com/apps/richdocumentscode richdocumentscode app] which bundles the CODE server. While being less performant than a standalone deployment of the CODE server, this solution does not require an additional service to be deployed and managed externally from NextCloud. Unfortunately the richdocumentscode app bundles the CODE server as an AppImage and therefore does not work out of the box on NixOS. Follow https://github.com/NixOS/nixpkgs/issues/339798 if you want to get informed about packaging progress. Also CODE standalone is currently not packaged in nixpkgs (https://github.com/NixOS/nixpkgs/issues/218878). | |||
[[Category:Server]] | [[Category:Server]] | ||
[[Category:Applications]] | [[Category:Applications]] | ||
[[Category:Web Applications]] | [[Category:Web Applications]] | ||
[[Category:NixOS Manual]] |