How to install Collabora Online Community Edition (CODE) on a GandiCloud VPS

This page will show you how to install Collabora Online Community Edition on a GandiCloud VPS server.

What is CODE?

Collabora Online is a powerful online office suite, based on LibreOffice, which allows you to edit and manipulate popular document formats while also working in collaborative mode.

Collabora functionality is integrated as a plugin into several web tools including NextCloud, OwnCloud, and Moodle. These plugins act as a ‘client’ and must be connected to a server which has CODE installed. CODE stands for Collabora Online Community Edition and is the version of the software for this kind of use case.

Note

There is a CODE BuiltIn plugin, but it is not recommended for production by publishers, and cannot be installed on a Gandi’s Web Hosting instance.

This tutorial will show you how to install CODE on a Gandi VPS. You can then connect this server to a NextCloud plugin, or any other service requiring a CODE server.

Prerequisites

You will need to have a GandiCloud VPS. A VR-1 server will be sufficient, and you can always increase the size of the server later if needed.

In this tutorial, we will install CODE behind an Nginx reverse proxy which will enable CODE to connect via https. It is also possible to use Apache or to install it stand-alone (without a proxy server).

In this tutorial we will be installing CODE on a Debian system, though Debian is not required.

Initial Setup

To start, you will SSH into the server and update system packages and make sure cURL is installed.

apt update && sudo apt upgrade -y && sudo apt install curl -y

Install Nginx

Nginx will play the role of reverse proxy: it will receive incoming requests and relay them to the CODE server. The server will also manage the TLS connection.

The server will need a name defined at the system level and at the DNS level. In the following example we will use the name “code.example.com”, which you should replace with your own name.

Replace “code.example.net” in the existing line in /etc/hostname.

echo code.example.net > /etc/hostname

Then, run the following command:

hostname code.example.com

SSL certificate:

Here, you have three options: use a self-signed certificate, a Gandi certificate or a Let’s Encrypt certificate.

In this tutorial we will use a standard 3-month Let’s Encrypt certificate.

First, you will install `Certbot<https://certbot.eff.org/>`_ using the following command:

apt install certbot

Then you will launch the generation of a certificate using the Nginx server. Again, don’t forget to replace “code.example.com” with your domain name.

certbot certonly -d code.example.com``

For the challenge choose option 2, “Place files in webroot directory (webroot)” and specify the default nginx root folder “/var/www/html”.

Configure vhost

It is assumed that the backend will be reachable on the default CODE port 9980.

Create the following file: /etc/nginx/sites-available/code.example.com.conf

Then in the file add the following:

server {
listen       443 ssl;
server_name  code.example.com;

ssl_certificate /etc/letsencrypt/live/code.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/code.example.com/privkey.pem;


# static files
location ^~ /browser {
  proxy_pass http://127.0.0.1:9980;
  proxy_set_header Host $http_host;
}


# WOPI discovery URL
location ^~ /hosting/discovery {
  proxy_pass http://127.0.0.1:9980;
  proxy_set_header Host $http_host;
}


# Capabilities
location ^~ /hosting/capabilities {
  proxy_pass http://127.0.0.1:9980;
  proxy_set_header Host $http_host;
}


# main websocket
location ~ ^/cool/(.*)/ws$ {
  proxy_pass http://127.0.0.1:9980;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
  proxy_set_header Host $http_host;
  proxy_read_timeout 36000s;
}


# download, presentation and image upload
location ~ ^/(c|l)ool {
  proxy_pass http://127.0.0.1:9980;
  proxy_set_header Host $http_host;
}


# Admin Console websocket
location ^~ /cool/adminws {
  proxy_pass http://127.0.0.1:9980;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
  proxy_set_header Host $http_host;
  proxy_read_timeout 36000s;
 }
}

Activate the ‘vhost’:

cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/code.example.com.conf /etc/nginx/sites-enabledcode.example.com.conf

Then, you can test the validity of the syntax:

nginx -t

And restart the service:

systemctl restart nginx

Installing CODE Community Edition

In the following example we will use the repo for Debian 11. You can find repos for other Linux distros, as well as additional instructions, in `Corella's CODE setup guide<https://www.collaboraoffice.com/code/linux-packages/>`_.

Added repository:

To add the repository, first open the file /etc/apt/`sources.list.d/collaboraonline.sources.

vi /etc/apt/sources.list.d/collaboraonline.sources

Then add the following content to the file:

Types: deb
URIs: https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-debian11
Suites: ./
Signed-By: /usr/share/keyrings/collaboraonline-release-keyring.gpg

Installing packages

Next, install the packages coolwsd and code-brand.

apt update && apt install coolwsd code-brand

CODE Setup

Next, you will need enable logging.

Create the file /var/log/coolwsd.log and assign it the properties root:cool as well as the rights 770.

touch /var/log/coolwsd.log
chown root:cool /var/log/coolwsd.log
chmod 770 /var/log/coolwsd.log

Now you will disable SSL support.

In our example, the TLS connection is handled by Ngin. Therefore we must disable it in CODE because otherwise the server will not start as it will not be able to find the certificate files.


coolconfig set ssl.enable false

You will also want to specify that the reverse proxy manages SSL.

coolconfig set ssl.termination true

Next, enter the URL of your NextCloud installation. We have used “nextcloud.example.com”, which you should replace with your own URL. Your NextCloud server must be reachable by https.

coolconfig set storage.woopi.host nextcloud.example.com

You will then make sure your CODE server is not directly accessible.

coolconfig set net.proto ipv4
coolconfig set net.listen loopback

Now, you will define an admin account.

coolconfig set-admin-password

Last, you will then restart the service.

systemctl restart coolwsd

You can now connect to this interface with the following URL, being sure to replace “code.example.com” with the name you used for your code server in earlier steps.

`https://code.example.com/browser/dist/admin/admin.html`_

Configure your NextCloud:

Now that your CODE server is set up you can configure your NextCloud to use it.

To start, from the “administrator” account, go to the “applications” menu.

In the list of appplication categories choose “office automation”.

Install the “Nextcloud office” application.

Then, via the menu “administration settings” go to “edit preferences” and find “Nextcloud Office” in the administration section (not the personal section). Also check disable SSL certificate verification if you are using a self-signed certificate on your server.

Save the configuration. If the connection is working the a green check will appear showing that the server is validated.

You can then go and create a new document in your user folder. You should now see several new types of documents available including text document, spreadsheet, presentation, and diagram.