Nextcloud and OnlyOffice Integration on FreeNAS

Update (10/08/2020): For the most recent version of this resource, refer to Nextcloud and OnlyOffice Integration in the Resources section of the FreeNAS Community Forum.

Resource

Collabora and OnlyOffice are popular office suite choices for Nextcloud. This is a collection of notes on how to get OnlyOffice working in Nextcloud behind a reverse proxy on FreeNAS. To realise this, a number of building blocks need to be put together.

Credits

@danb35: Nextcloud and Caddy resources
@kevdog: Collabora configuration, Docker Compose

IMPORTANT NOTE: If you have issues with steps 1 and 2 below, please DO NOT post those issues in the discussion area for this resource. However, in the context of Nextcloud-OnlyOffice integration, if you have some useful information on steps 1 and 2 that may benefit other forum members, please post your experience in the discussion area here.

Outline of the Steps

  1. Install Nextcloud
  2. Set up Nextcloud behind a reverse proxy
  3. Install Ubuntu with Docker and Docker Compose in a FreeNAS VM
  4. Install the OnlyOffice Document Server using Docker Compose
  5. Set up the OnlyOffice Document Server behind the reverse proxy
  6. Enable and configure the OnlyOffice connector in Nextcloud
  7. OnlyOffice automatic updates (optional)

You may be able to cherry-pick from these steps if you already have some of the building blocks in place.

Note: For the purpose of explanation, the steps below assume that the Nextcloud FQDN is cloud.mydomain.com and for OnlyOffice, it is office.mydomain.com.

Step 1: Install Nextcloud

I used @danb35‘s Scripted installation of Nextcloud 18 in iocage jail resource to set up a new Nextcloud service.

Notes:

  1. Importantly, set HOST_NAME=”cloud.mydomain.com” and NO_CERT=1 in the script configuration file nextcloud-config. The reason for setting NO_CERT=1 is that a separate reverse proxy will provide certificate services and TLS termination for Nextcloud.

Q1. I’m having problems getting Nextcloud working using the script?

Raise your issues in the discussion area for the script. Please don’t raise your issues in the discussion area here. Do not proceed to step 2 until you have Nextcloud working.

Q2. I’ve set up Nextcloud using a different resource and I’m having issues getting Nextcloud working?

You may have used a different resource to set up Nextcloud. You should refer any issues you have with that resource provider. If you’ve set up Nextcloud using the plugin, raise your issues in the forum. Do not raise your Nextcloud issues here as I’m unable to provide any assistance when it comes to debugging Nextcloud. Do not proceed to step 2 until you have Nextcloud working.

Q3. I have an existing Nextcloud service. Can I still integrate OnlyOffice into it?

Well, that depends. At the time of writing this, I’m working with Nextcloud version 18.0.3, OnlyOffice Document Server version 5.5.1.76 and FreeNAS 11.3-U1. I’m unable to comment on OnlyOffice integration with earlier versions of Nextcloud or FreeNAS. Try it, and whether it works or not, let the FreeNAS community know about your experience here.

Q4. How will I know Nextcloud is working, and I can proceed to step 2?

Firstly, you’ll be able to see the Nextcloud login page when you enter its jail IP e.g. http://10.1.1.29 in a browser. Secondly, the Nextcloud Administration Overview should show just one warning.

screenshot.244.png

I used @danb35’s Reverse Proxy using Caddy (with optional automatic TLS) resource to set up a reverse proxy including automatic HTTPS using TLS with HTTP validation, and with Cloudflare providing DNS hosting.Notes:

  1. Importantly, your local DNS resolver must resolve mydomain.com to your Caddy jail IP.
  2. For certificate renewal, ports 80 and 443 must be forwarded to the Caddy jail.
  3. In Cloudflare, set up a CNAME record for the subdomain cloud.mydomain.com.
  4. The Caddyfile code block for Nextcloud will look something like:
cloud.mydomain.com {
   gzip
   proxy / http://10.1.1.29 {
     transparent
   }
}

Q1. I’m having problems getting Nextcloud working with Caddy?

Raise your issues in the discussion area for the Caddy resource. Please don’t raise your issues in the discussion area here. Do not proceed to step 3 until you have Nextcloud working with Caddy.

Q2. I’ve set up a reverse proxy using a different resource and I’m having issues getting Nextcloud working with it?

You may have used a different resource to set up a reverse proxy. You should refer any issues you have with that resource provider. Do not raise your reverse proxy issues here as I do not have any depth of experience with reverse proxies. Do not proceed to step 3 until you have Nextcloud working with the reverse proxy.

Q3. How will I know Nextcloud is working with a reverse proxy such as Caddy, and I can proceed to step 3?

If you’ve set up a landing page in Caddy, entering https://mydomain.com in a browser will reach the landing page. Similarly, entering https://cloud.mydomain.com in the browser will reach the Nextcloud login page. In addition, the Nextcloud Administration Overview should now show no warnings. Do not proceed to step 3 until you get these results

screenshot.252.png

Step 3: Install Ubuntu with Docker and Docker Compose in a FreeNAS VM

Refer to Installing Docker in the FreeNAS User Documentation.

Install Docker Compose.

Notes:

  1. For the VM characteristics, I used what I saw in Figure 18.1.2 in the previous section of the User Documentation. This worked well for me.
  2. I installed Ubuntu 18.04.4 Desktop.
  3. Don’t forget the post-installation step of setting up Docker to start on boot.
  4. Set up a static IP for the Ubuntu host.
  5. Cut and paste isn’t possible with the VNC supplied in the FreeNAS UI. Enable SSH in the Ubuntu VM so you can SSH into it using an SSH client like PuTTY. You will then be able to cut and paste into the terminal.

Q1. How will I know Docker and Docker Compose are working correctly, and I can proceed to step 4?

The Docker engine correctly runs the hello-world image, even after a restart of the VM. Do not proceed to the next step until you get this result.

Test the Docker Compose installation with docker compose --version

Step 4: Install the OnlyOffice Document Server using Docker Compose

Change to the home directory cd and create a directory for the Compose file mkdir onlyoffice. Change to the directory cd onlyoffice. Create the Compose file nano docker-compose.yml and paste the following:

version: '3.3'
services:
  documentserver:
    ports:
      - '80:80'
    restart: always
    container_name: onlyoffice-document-server
    image: onlyoffice/documentserver

References:

  1. GitHub: ONLYOFFICE / Docker-DocumentServer
  2. Composerize

Build and run OnlyOffice Document Server with Compose sudo docker-compose up -d.

Q1. How will I know the OnlyOffice Document Server is working correctly, and I can proceed to step 5?

On startup, it can take a few minutes for the OnlyOffice Document Server to stabilise. You can monitor the progress of server initialisation using sudo docker logs -f  onlyoffice-document-server to view the server log (Ctrl-C). There are a couple of useful indicators that the OnlyOffice Document Server has started properly:

You know you’re approaching the end of server initialisation when last few lines of the log look something like the following:

[2020-04-29T13:48:45.698] [WARN] nodeJS - start cluster with 1 workers
[2020-04-29T13:48:45.749] [WARN] nodeJS - worker 823 started.
[2020-04-29T13:48:47.958] [WARN] nodeJS - Express server starting...
[2020-04-29T13:48:48.137] [WARN] nodeJS - Express server listening on port 8080 in production-linux mode

Next, you’ll also see the OnlyOffice Document Server welcome banner when you enter the Ubuntu host IP e.g. http://10.1.1.21 in a browser. Do not proceed to step 5 until you get these results.

.screenshot.305.png

Step 5: Set up the OnlyOffice Document Server behind the reverse proxy

Notes:

  1. In Cloudflare, set up a CNAME record for the subdomain office.mydomain.com.
  2. If using Caddy, the Caddyfile code block for OnlyOffice will look something like:
office.mydomain.com {
  gzip
  proxy / http://10.1.1.21 {
    transparent
  }
}

Q1. How will I know OnlyOffice is working with a reverse proxy such as Caddy, and I can proceed to step 6?

Entering https://office.mydomain.com in a browser directs you to the OnlyOffice Document Server welcome banner seen in the previous step. Do not proceed to the next step until you get this result.

Step 6: Enable and configure the OnlyOffice connector in Nextcloud

Notes:

  1. Don’t enable the Community Document Server that you see in the Hub bundle as it is a Linux image and doesn’t run under FreeBSD. It can probably be removed.
  2. Enable the ONLYOFFICE connector in the Hub bundle and configure it as shown below.

screenshot.245.png

screenshot.308.png

Q1. How will I know the OnlyOffice connector has been set up properly?

On clicking Save, you should see the message ‘Settings have been successfully updated’ flash up for several seconds towards the top RHS of the screen. If you don’t see this message, check the paths to your Nextcloud and Document Server.

That’s pretty much it.  Logging in as a Nextcloud user now gives you access to the OnlyOffice suite including a word processor, spreadsheet and presentation applications. To see what’s on offer, have a look at the marketing spiel including a video here. There are also free OnlyOffice desktop and mobile (iOS and Android) apps that work with Nextcloud.

Step 7: OnlyOffice Automatic Updates

This is an optional step. It is not required for Nextcloud-OnlyOffice integration. What it does is aim to ensure that Nextcloud has access to the latest version of OnlyOffice Document Server. A check is done daily for a new version of the OnlyOffice image. If a new version exists, it is downloaded and the OnlyOffice container updated. The old image is then removed.

The following assumes that you’ve adhered closely to Step 4 above and your Compose file is stored in the OnlyOffice folder within the home directory.

Change to the OnlyOffice folder cd $HOME/onlyoffice. Create the update.sh script nano update.sh and paste the following:

#!/bin/bash
date
cd "`dirname "$0"`"
docker-compose pull
docker-compose up -d
docker image prune -f
date
echo

Reference: CODE docker automatic update

Make the file executable chmod +x update.sh.

Next, we’re going to add a line, that takes the form below, to the system-wide crontab.

m h * * * /path/to/script >> /path/to/log 2>&1

References:

  1. Ubuntu Crontab
  2. Understanding Shell Script’s idiom: 2>&1

Standard and error output will be appended to /path/to/log. By design, the log file will be placed in the OnlyOffice folder as well, so:

/path/to/script = $HOME/onlyoffice/update.sh
/path/to/log = $HOME/onlyoffice/update.log

However, we need to use the evaluated version of $HOME for the system-wide crontab. Make a note of what this is echo $HOME.

For example:

screenshot.341

For this example:

/path/to/script = /home/administrator/onlyoffice/update.sh
/path/to/log = /home/administrator/onlyoffice/update.log

Edit the system-wide crontab sudo crontab -e and set up the cron job.

The script should be run at a time when it’s unlikely anyone will be using OnlyOffice. In the example below, I’m checking for updates daily at 20 minutes after midnight.

20 0 * * *  /home/administrator/onlyoffice/update.sh >> /home/administrator/onlyoffice/update.log 2>&1

If there isn’t an update when the job is run, a typical log entry will look something like the following:

screenshot.337

If an update is available, the log entry will instead look more like this:

screenshot.339

 

 

Keep Reading

PreviousNext

2 thoughts on “Nextcloud and OnlyOffice Integration on FreeNAS

  1. Hi,
    Might I ask you a question? I am trying to follow this guide to setup the Document server, and I get as far as trying to access the Document servers IP in a web browser. I get a ERR_CONNECTION_REFUSED message there. Running docker ps tells me that onlyoffice/documentserver has been up for less than a second. Even if I wait for a minute. nginx error.log reports exits on code 9. Upped memory for the VM to 4GB, but that didn´t help. Could you give any pointers as to might have gone wrong?

Leave a Reply