Nextcloud offers different configuration methods. While some folks prefer editing the configuration file using their favourite editor like nano
, vim
or UI texteditors like gedit, kedit etc. the OCC management console is a safe and comfortable method to configure your instance.
Regardless of the method you prefer, be sure to backup your configuration before editing! Take care to preserve the syntax and special characters, as incorrect formatting or misplaced characters and spaces may render your Nextcloud unusable. So be sure to backup the original config.php
file before editing.
TIP
Some systems don’t add /snap/bin to the PATH. Try
sudo /snap/bin/nextcloud.occ
How to edit config.php
for Nextcloud snap
Some Nextcloud snap settings may need to be done directly in the config.php
configuration file. While the default configurations are mostly fine, you might want to fine tune your Nextcloud snap instance.
TIP
Nextcloud documentation
Nextcloud snap, editing configuration file
The configuration file can be edited manually.
IMPORTANT
Take care to preserve the syntax and special characters, as incorrect formatting or misplaced characters and spaces may render your Nextcloud unusable. So be sure to backup the original
config.php
file before editing.
- Backup
config.php
sudo cp /var/snap/nextcloud/current/nextcloud/config/config.php config.php.bak
- Edit
config.php
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php
Setting trusted domains
Adding multiple trusted domains manually in config.php
:
- edit
config.php
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php
and add/edit section
'trusted_domains' =>
array (
0 => 'cloud.yourdomain.xyz',
1 => 'cloud.yourotherdomain.zxy',
2 => 'localhost',
3 => 'nextcloud.local',
),
or issue occ command on host (iterating values 0, 1, 2…):
sudo nextcloud.occ config:system:set trusted_domains 0 --value=cloud.yourdomain.xyz
CAUTION
Be aware that the values for
trusted_domains
should be domain names (see FQDN). IP addresses are not domains! See hosts & FQDN configuration.
Setting trusted proxies
Adding trusted proxies manually in config.php
:
edit config.php
and add/edit section
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php
'trusted_proxies' =>
array (
0 => 'your.reverse.proxy.ip',
1 => 'your.other.proxy.ip',
),
or issue occ command on host (iterating values 0, 1, 2…):
sudo nextcloud.occ config:system:set trusted_proxies 0 --value="your.reverse.proxy.ip"
CAUTION
Be aware that these values should be IPv4 or IPv6 addresses in CIDR notation see reverse proxy documentation
Setting overwrite parameters
Nextcloud overwrite parameters such as overwriteprotocol
and overwritehost
are two configs that absolutely depend on your reverse proxy setup.
Be aware that some devices require an additional setting in config.php
if your Nextcloud snap instance is behind a reverse proxy.
For internet facing Nextcloud snap that handles encryption itself or a pass-through reverse proxy is present it shouldn’t be necessary to set overwriteprotocol
and overwritehost
.
edit config.php
and add/edit section
'overwriteprotocol' => 'https',
'overwritehost' => 'cloud.yourdomain.xyz',
or issue occ command on host:
sudo nextcloud.occ config:system:set overwriteprotocol --value="https"
sudo nextcloud.occ config:system:set overwritehost --value="cloud.yourdomain.xyz"
Setting default maintenance window
Set default maintenance window time 01:00 (1 a.m.)
edit config.php
and add/edit line in config.php
'maintenance_window_start' => 1,
or issue occ command on host:
sudo nextcloud.occ config:system:set maintenance_window_start --value="1"
Setting default phone region
edit config.php
and add/edit line in config.php
'default_phone_region' => 'GB',
or issue occ command on host:
sudo nextcloud.occ config:system:set default_phone_region --value="GB"
Setting default language
edit config.php
and add/edit line in config.php
'default_language' => 'en',
or issue occ command on host:
sudo nextcloud.occ config:system:set default_language --value="en"
Setting default locale
edit config.php
and add/edit line in config.php
'default_locale' => 'en_GB',
or issue occ command on host:
sudo nextcloud.occ config:system:set default_locale --value="en_GB"
Setting default landing app
edit config.php
and add/edit line in config.php
default value is
""
(empty)
'defaultapp' => '<appname>',
or issue occ command on host:
sudo nextcloud.occ config:system:set defaultapp --value="<appname>"
example: sudo nextcloud.occ config:system:set defaultapp --value="mail"
or
Setting Talk push notification
edit config.php
and add/edit line in config.php
'has_internet_connection' => 'true',
or issue occ command on host:
sudo nextcloud.occ config:system:set has_internet_connection --value="true"
Setting default folder for shares
edit config.php
and add/edit line in config.php
'share_folder' => '/SHARE_with_others',
or issue command on host:or issue occ command on host:
sudo nextcloud.occ config:system:set share_folder --value="/SHARE_with_others"
Setting default folder for shared with me
edit config.php
and add/edit line in config.php
'share_folder' => '/SHARED_with_me',
or issue occ command on host:
sudo nextcloud.occ config:system:set share_folder --value="/SHARED_with_me"
Setting trashbin retention
NOTE
The default setting keeps files and folders in the trashbin for 30 days and automatically deletes anytime after that if space is required.
add/edit line in
config.php
and addtrashbin_retention_obligation
'trashbin_retention_obligation' => 'auto',
to enable the background job issue command:
sudo nextcloud.occ config:app:delete files_trashbin background_job_expire_trash
Example: keep files and folders in the trash bin for at least 90 days and delete when exceeds 120 days
edit config.php
and add/edit line in config.php
'trashbin_retention_obligation' => '90, 120',
or issue occ command on host:
sudo nextcloud.occ config:system:set trashbin_retention_obligation --value="90, 120"
to enable the background job issue command:
sudo nextcloud.occ config:app:delete files_trashbin background_job_expire_trash
to disable the background job issue command:
sudo nextcloud.occ config:app:set --value=no files_trashbin background_job_expire_trash
see docs: Deleted Items (trash bin) — Nextcloud latest Administration Manual latest documentation
TIP
Be aware that files may not be deleted automatically if space is available.
To cleanup the trashbin manually run:sudo nextcloud.occ trashbin:cleanup --all-users
also note, there is a difference between trashbin and groupfolders-trashbin. To cleanup groupfolders-trashbin run:
sudo nextcloud.occ groupfolders:trashbin:cleanup -f
Skeleton for default Nextcloud documents, files and folders etc.
Default documents, files and folders for new users may be placed in a “skeleton” directory. Thus new users will find documents files an folders in their Nextcloud upon first login.
Create a skeleton directory /var/snap/nextcloud/common/skeleton
sudo mkdir /var/snap/nextcloud/common/skeleton
Add your default files folders here. You may also add group folders here. See Group folders app
edit config.php
and add skeleton directory path
'skeletondirectory' => '/var/snap/nextcloud/common/skeleton',
or issue occ command on host:
sudo nextcloud.occ config:system:set skeletondirectory --value="/var/snap/nextcloud/common/skeleton"
Secure session cookie
'session.cookie_secure' => 'true',
or issue command on host:
sudo nextcloud.occ config:system:set session.cookie_secure --value="true"
Remove signup link
edit config.php
and add/edit line in config.php
'simpleSignUpLink.shown' => false,
or issue occ command on host:
sudo nextcloud.occ config:system:set simpleSignUpLink.shown --value="false"
Disable reset password link
If your user backend does not allow password resets (e.g. when it’s a read-only user backend like LDAP), disable password reset link
edit config.php
and add/edit line in config.php
'lost_password_link' => 'disabled',
or issue occ command on host:
sudo nextcloud.occ config:system:set lost_password_link --value="disabled"
you can specify a custom link, where the user is redirected to, when clicking the “reset password” link after a failed login-attempt
'lost_password_link' => 'https://example.org/link/to/password/reset',