Monday, October 1, 2018

Install Nextcloud as Docker container on Synology NAS

You can find guides out there explaining how to install Nextcloud as a Docker container, or rather as a number of containers, since you'll normally need a few supporting containers (DB, reverse proxy, etc.). However, I wanted to explore a simple way to set up Nextcloud, and I wanted to do it on my Synology NAS. Basically, what I wanted to do was the following:

  • Setup Nextcloud (using built-in SQLite database) Docker container on Synology NAS
  • Expose Nextcloud through Synology NAS built-in reverse proxy
  • Create and use a Let's Encrypt certificate for HTTPS
This guide assumes your Synology NAS supports Docker and you've already installed the Synology Docker app on your Synology NAS. The guide furthermore assumes you are using a Synology NAS volume called "volume1". If not, just replace with name of the volume you are using.
The guide is based on DSM 6.2.
  1. Go to where you administer your domains and add an A-record for a new subdomain, e.g. nextcloud.yourdomain.com
  2. Go to your router administration interface and setup port forwarding, e.g.: external-ip:6443 -> internal-ip:6301.
    Note: I'm using the port 6443 externally because that's what I want. I your case, you may want to use the standard SSL port 443, or something else entirely.
  3. Log in to Synology DSM, open Control Panel/Security/Certificate, and create a new Let's Encrypt certificate (since the default Synology certificate is NOT a trusted one):
    • Press "Add"
    • Select "Add a new certificate" and press "Next"
    • Select "Get a certificate from Let's Encrypt" and press "Next"
    • Enter the information needed by Let's Encrypt and press "Apply"
  4. Go to Control Panel/Application Portal/Reverse Proxy, and create a new entry:
    • Source: HTTPS, nextcloud.yourdomain.com, 6443, Enable HSTS
    • Destination: HTTP, localhost, 6301
  5. Go back to Control Panel/Security/Certificate, and press "Configure", then for "nextcloud.yourdomain.com:6443" select your newly created Let's Encrypt certificate.
  6. SSH into your Synology NAS (e.g. with PuTTy) using an account with administrative rights.
  7. Create a new folder called "nextcloud" located in "volume1/docker". This will be used to store all your Nextcloud data, so when you upgrade the Docker container your data remain in place.
    mkdir /volume1/docker/nextcloud
  8. Pull the Nextcloud image and run it as a container using the following command (note: it is recommended to pull/run using command line since Synology Docker app is limited in what you can configure):
    sudo docker run -d --name nextcloud -p 6301:80 -v /volume1/docker/nextcloud:/var/www/html nextcloud
You should now be able to open a browser and go to: https://nextcloud.yourdomain.com:6443 without any problems (even in Firefox :-)

Part 2:

Ok, so I installed Nextcloud. What I really wanted to use it for was for bookmark synchronization across browsers. With the unfortunate demise of Xmarks, I needed some other way of keeping all my bookmarks in sync, and this time I wanted to control everything myself, so I didn't have to rely on the potentially unreliable existence of yet another 3rd party cloud service.

In order to use Nextcloud for bookmarks, the first thing I did was to install an app called "Bookmarks". The term "app" can mean a lot of things these days, but in this case it means that you log in to your Nextcloud web interface, locate the app store, and find the app called "Bookmarks" and install it.

Next thing I did was installing the Floccus browser extension in the various browsers I use, and then I followed the Floccus instructions for how to sync bookmarks.

Saturday, July 14, 2018

Install Ubiquiti UniFi Controller as Docker container on Synology NAS

It's assumed your Synology NAS supports Docker and you've already installed the Synology Docker app on your Synology NAS. The guide assumes you are using a Synology NAS volume called "volume1". If not, just replace with name of the volume you are using.

  1. SSH into your Synology NAS (e.g. with PuTTy) using an account with administrative rights.
  2. Create a new folder called "unifi" located in "volume1/docker". This will be used to store all your UniFi Controller configs, so when you upgrade the Docker container your configs remain in place.
    mkdir /volume1/docker/unifi
  3. Pull the UniFi Controller Docker image from Docker Hub by typing the following command:
    sudo docker pull linuxserver/unifi-controller:latest
  4. Run the new UniFi Controller container using the following command (note: you can't do this using the Synology Docker app, since it's not possible to set all the configuration correctly through the UI):
    sudo docker run -d --name=unifi-controller --net=host --volume=/volume1/docker/unifi:/config -p 3478:3478/udp -p 10001:10001/udp -p 8080:8080 -p 8081:8081 -p 8443:8443 -p 8843:8843 -p 8880:8880 -p 6789:6789 linuxserver/unifi-controller:latest
  5. Finally, open a web browser and go to: https://<SYNOLOGY_IP>:8443

Note: If you are going to adopt an existing UniFi Access Point, it may be necessary to reset it to factory settings before the controller will be able to discover it (well, it was for me at least).

Update (Nov. 24 2019): Updated commands to reflect UniFi image renaming (was: linuxserver/unifi, now is: linuxserver/unifi-controller)