Nextcloud is a suite of client-server software for creating and using file hosting services. Nextcloud recently changed its name to Nextcloud Hub 9. It’s free and open-source which means that anyone is allowed to install and operate it on their own private server devices. In this step by step guide I will show you how to install Nextcloud Hub 9 on your Synology NAS using Docker & Portainer.
STEP 1
Please Support My work by Making a Donation.
STEP 2
Install Portainer using my step by step guide. If you already have Portainer installed on your Synology NAS, skip this STEP. Attention: Make sure you have installed the latest Portainer version.
STEP 3
Make sure you have a synology.me Wildcard Certificate. Follow my guide to get a Wildcard Certificate. If you already have a synology.me Wildcard certificate, skip this STEP.
STEP 4
Go to Control Panel / Login Portal / Advanced Tab / click Reverse Proxy. Follow the instructions in the image below.
STEP 5
Now click the “Create” button. Follow the instructions in the image below.
STEP 6
After you click the Create button, the window below will open. Follow the instructions in the image below.
On the General area, set the Reverse Proxy Name description: type in Nextcloud. After that, add the following instructions:
Source:
Protocol: HTTPS
Hostname: nextcloud.yourname.synology.me
Port: 443
Check Enable HSTS
Destination:
Protocol: HTTP
Hostname: localhost
Port: 8082
STEP 7
On the Reverse Proxy Rules click the Custom Header tab. Click Create and then, from the drop-down menu, click WebSocket. After you click on WebSocket, two Header Names and two Values will be automatically added. Click Save. Follow the instructions in the image below.
STEP 8
On the Reverse Proxy Rules, click the Advanced Settings tab.
- Increase the Proxy connection timeout from 60 to 600 seconds.
- Increase the Proxy send timeout from 60 to 600 seconds.
- Increase the Proxy read timeout from 60 to 600 seconds.
Click Save to save the settings.
STEP 9
Go to Control Panel / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.
STEP 10
Go to Control Panel / Security / Advanced tab/ Check Enable HTTP Compression then click Apply. Follow the instructions in the image below.
STEP 11
Go to File Station and open the docker folder. Inside the docker folder, create one new folder and name it nextcloud. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.
STEP 12
Now create seven new folders inside the nextcloud folder that you created at STEP 11 and name them config, custom_apps, data, db, html, redis, themes. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.
STEP 13
Download (click on the blue link below) and upload the my.cnf file below in the db folder that you have previously created at STEP 12. Follow the instructions in the image below. 🔒Note: Support my work to unlock the password. You can use this password to download any file on mariushosting forever!
STEP 14
Right click on the nextcloud folder that you have previously created at STEP 11 then click Properties. Follow the instructions in the image below.
STEP 15
Go to the Permission tab then click Advanced options. From the drop-down menu choose “Make inherited permissions explicit“. Follow the instructions in the image below.
STEP 16
Select Everyone then click the Edit tab. Follow the instructions in the image below.
STEP 17
Check all Read and Write Permissions. Click Done. Follow the instructions in the image below.
STEP 18
After you click Done on STEP 17, check “Apply to this folder, sub-folders and files“. Click Save. Follow the instructions in the image below.
STEP 19
Log into Portainer using your username and password. On the Portainer left sidebar click on Stacks then + Add stack. Follow the instructions in the image below.
STEP 20
In the Name field type in nextcloud. Follow the instructions in the image below.
services: mariadb: container_name: Nextcloud-DB image: mariadb:11.4-noble #LTS Long Time Support Until May 29, 2029. security_opt: - no-new-privileges:false command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-read-only-compressed=OFF volumes: - /volume1/docker/nextcloud/db:/var/lib/mysql:rw - /volume1/docker/nextcloud/db:/etc/mysql/conf.d:rw environment: - MYSQL_ROOT_PASSWORD=rootpass - MYSQL_PASSWORD=mariushosting - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - TZ=Europe/Bucharest restart: on-failure:5 redis: image: redis container_name: Nextcloud-REDIS hostname: nextcloudredis user: 1026:100 healthcheck: test: ["CMD-SHELL", "redis-cli ping || exit 1"] volumes: - /volume1/docker/nextcloud/redis:/data:rw environment: TZ: Europe/Bucharest restart: on-failure:5 nextcloud: container_name: Nextcloud ports: - 8082:80 depends_on: mariadb: condition: service_started redis: condition: service_healthy environment: - REDIS_HOST=nextcloudredis - NEXTCLOUD_ADMIN_USER=marius - NEXTCLOUD_ADMIN_PASSWORD=mariuspass10 - NEXTCLOUD_TRUSTED_DOMAINS=nextcloud.yourname.synology.me 192.168.1.18 - TRUSTED_PROXIES=192.168.1.18 - OVERWRITEHOST=nextcloud.yourname.synology.me - OVERWRITEPROTOCOL=https - MYSQL_PASSWORD=mariushosting - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - MYSQL_HOST=mariadb healthcheck: test: curl -f http://localhost:80/ || exit 1 volumes: - /volume1/docker/nextcloud/html:/var/www/html:rw - /volume1/docker/nextcloud/custom_apps:/var/www/html/custom_apps:rw - /volume1/docker/nextcloud/config:/var/www/html/config:rw - /volume1/docker/nextcloud/data:/var/www/html/data:rw - /volume1/docker/nextcloud/themes:/var/www/html/themes:rw image: nextcloud restart: on-failure:5 cron: image: nextcloud:apache container_name: Nextcloud-CRON restart: always volumes: - /volume1/docker/nextcloud/config:/var/www/html/config:rw - /volume1/docker/nextcloud/html:/var/www/html:rw - /volume1/docker/nextcloud/custom_apps:/var/www/html/custom_apps:rw - /volume1/docker/nextcloud/data:/var/www/html/data:rw entrypoint: /cron.sh depends_on: mariadb: condition: service_started redis: condition: service_started
Note: Before you paste the code above in the Web editor area below, change the value for MYSQL_PASSWORD and MYSQL_PASSWORD. Type in your own password for both values; they have to be identical. mariushosting is an example for a password.
Note: After you paste the code in the Web editor, change the value for TZ (Select your current Time Zone from this list).
Note: Before you paste the code above in the Web editor area below, change the value numbers for user with your own UID and GID values. (Follow my step by step guide on how to do this.) 1026 is my personal UID value and 100 is my personal GID value. You have to type in your own values.
Note: Before you paste the code above in the Web editor area below, change the value for NEXTCLOUD_ADMIN_USER. Type in your own username. marius is an example for a username. You will need this username later at STEP 24.
Note: Before you paste the code above in the Web editor area below, change the value for NEXTCLOUD_ADMIN_PASSWORD. Type in your own password. mariushosting is an example for a password. You will need this password later at STEP 24.
Note: Before you paste the code above in the Web editor area below, change the value for NEXTCLOUD_TRUSTED_DOMAINS with your own synology.me DDNS without https:// at the beginning that you have previously created at STEP 6. Type in your own local NAS IP. The DDNS and your own local NAS IP are separated by space. 192.168.1.18 is my NAS local IP. You should add your own NAS local IP.
Note: Before you paste the code above in the Web editor area below, change the value for TRUSTED_PROXIES with your own synology.me DDNS. Type in your own local NAS IP. 192.168.1.18 is my NAS local IP. You should add your own NAS local IP.
Note: Before you paste the code above in the Web editor area below, change the value for OVERWRITEHOST with your own synology.me DDNS without https:// at the beginning that you have previously created at STEP 6.
STEP 21
Scroll down on the page until you see a button named Deploy the stack. Click on it. Follow the instructions in the image below. The installation process can take up to a few minutes. It will depend on your Internet speed connection.
STEP 22
If everything goes right, you will see this message at the top right of your screen: “Success Stack successfully deployed“.
STEP 23
Go back to STEP 1 or you will deal with karma 🙂.
STEP 24
You should wait 3-4 minutes because the installation process will take some time. Now open your browser and type in your HTTPS/SSL certificate like this https://nextcloud.yourname.synology.me In my case it’s https://nextcloud.mariushosting.synology.me If everything goes right, you will see the Nextcloud main page. Type in your own Username (NEXTCLOUD_ADMIN_USER) and Password (NEXTCLOUD_ADMIN_PASSWORD) that you have previously added at STEP 20, then click Log in. Follow the instructions in the image below.
STEP 25
Close the pop-up. Follow the instructions in the image below.
STEP 26
Your Nextcloud Installation will look like this.
STEP 27
Activate Cronjobs. At the top right of the page click on your profile icon then Administration settings. On the left sidebar click Basic settings then check Cron. Follow the instructions in the image below.
STEP 28
At the top right of the page click View profile then Edit Profile. Follow the instructions in the image below.
STEP 29
Type in your own Gmail Address then click Basic settings. Follow the instructions in the image below.
STEP 30
Follow my step by step guide on how to activate SMTP for your Gmail account. This step is mandatory. Note: If you don’t want to use the easiest way for SMTP with Google and you already have SMTP details from your own Mail Server, you can just skip this STEP and use your personalized email SMTP details instead.
STEP 31
On the Email server area type in your own Email details then click Save. Click Send email. Follow the instructions in the image below.
STEP 32
Check your email. Follow the instructions in the image below.
STEP 33
You can also Add Gmail Details to Nextcloud Mail.
STEP 34
Let’s fix carddav and caldav! In File Station go to the nextcloud folder then html. Download the .htaccess file to your computer then open it with Notepad. From the .htaccess file remove these two lines below:
RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L] RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
And replace with these lines below.
RewriteRule ^\.well-known/carddav https://nextcloud.yourname.synology.me/remote.php/dav/ [R=301,L] RewriteRule ^\.well-known/caldav https://nextcloud.yourname.synology.me/remote.php/dav/ [R=301,L]
See the example in the image below.
Save the .htaccess file then upload it to the html folder. Warning: Remember to delete the old .htaccess file in the html folder and then upload your new .htaccess file. Also, it’s mandatory to add the (dot) . at the beginning of the .htaccess file to make it work. If you forget the dot at the beginning of the file, this will not work.
Enjoy your Nextcloud via Docker!
Note: What if I get error 0770? Your data directory is readable by other users.
Please change the permissions to 0770 so that the directory cannot be listed by other users.
If you get this error Right click on the nextcloud folder in File Station then click Properties. Click on the Permission tab then go to the Advanced options. Select Make inherited permissions explicit. Now Select User “Everyone” then Delete it using Delete tab. Check “Apply to this folder, sub-folders and files”. Click Save.
💡Note: If Maintenance mode is ON after upgrading Nextcloud to version 29 and you can’t access your Nextcloud instance, check the solution below.
Access the Nextcloud container console in Portainer, then type in the following code:
#runuser --user www-data ./occ upgrade
After that, edit the /volume1/docker/nextcloud/config/config.php file in the nextcloud folder in File Station and set the maintenance mode to false.
Note: Find out how to update Nextcloud container with the latest image.
Note: Can I run Docker on my Synology NAS? See the supported models.
Note: How to Back Up Docker Containers on your Synology NAS.
Note: You can also install Nextcloud using the standard installation method for nextcloud.
Note: If you encounter mem_swappiness issue contact me for instructions on how to solve it.
Note: Nextcloud together with the OnlyOffice document server.
Note: How to Free Disk Space on Your NAS if You Run Docker.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.
This post was updated on Saturday / September 28th, 2024 at 5:14 PM