Install Nextcloud Server using snapcraft with Nginx reverse proxy and HTTPS enabled

Snap provides an approach to install Nextcloud easy and clean.

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

#Debian\Ubuntu: 

#As super user:

apt install snapd

snap install nextcloud

#Enter your domain into browser and you'll see the welcome page, opreate as instruction.

nextcloud.enable-https lets-encrypt

#Operate as instruction.

#Done.

To set nextcloud port different than default:

snap set nextcloud ports.https=8080

snap set nextcloud ports.https=8443

Ignore the following part if you don't need an Nginx proxy.

And refer: Offical docs

To set reverse proxy properly, we need to edit the config/config.php file, usually locates at /var/snap/nextcloud/(some numbers)/nextcloud/config/. Edit this file CAREFULLY with the guidance of the document and a backup made.

What you need to do is: edit the Nginx config file to set a reverse proxy which is easy to Google and I'm lazy to write; add the following part to Nginx configurationfile, too: https://docs.nextcloud.com/server/24/admin_manual/configuration_server/reverse_proxy_configuration.html#nginx. And add the trusted_proxies into nextcloud congif.php as:

  array (

          0 => '127.0.0.1',

          1 => '(your IPv6 address)(if have)',

  ),

Otherwise, some error occurs when login in via the Android app.

Run sudo snap restart nextcloud and everything should be fine! Enjoy!


No, not yet. Everything looks just fine, but "An unknown error occurs" when you are trying to upload any file greater than 1MB. It's the Nginx default upload file limit, solve it by adding the following part into /etc/nginx/nginx.conf:

http { 
     ... 
     client_max_body_size 100M ; ##or any size you need
 }     

Finally...