Snap provides an easy and clean way to install Nextcloud.

Prepare a domain name resolved to the IP address of your server.

1
2
3
# Debian/Ubuntu, as root:
apt install snapd
snap install nextcloud

Enter your domain in a browser, complete the setup shown on the welcome page, then enable HTTPS:

1
sudo nextcloud.enable-https lets-encrypt

To change the default Nextcloud ports:

1
2
sudo snap set nextcloud ports.http=8080
sudo snap set nextcloud ports.https=8443

Ignore the following section if you don’t need an Nginx proxy.

Refer to the official reverse-proxy documentation.

To configure the reverse proxy properly, edit config/config.php, usually located under /var/snap/nextcloud/current/nextcloud/config/. Make a backup first and edit this file carefully according to the documentation.

Configure Nginx as described in the Nginx section of the documentation, then add trusted_proxies to Nextcloud’s config.php:

1
2
3
4
5
'trusted_proxies' =>
array (
    0 => '127.0.0.1',
    1 => 'your IPv6 address, if applicable',
),

Without this setting, errors may occur when logging in through the Android app.

Run sudo snap restart nextcloud, and everything should be fine.


Not quite yet: everything may look fine, but “An unknown error occurred” can appear when uploading a file larger than 1 MB. This is caused by Nginx’s default upload limit. Add the following setting to /etc/nginx/nginx.conf:

1
2
3
4
http {
    # ...
    client_max_body_size 100M;  # Or any size you need
}

Finally—done.