Integrate Collabora Online with Nextcloud on Ubuntu without Docker

This tutorial is going to show you how to install Collabora Online on Ubuntu and then integrate it with an existing Nextcloud server without using Docker.

Collabora Online is a self-hostable and LibreOffice-based open-source online office suite. Its features include:

  • Basic editing
  • High fidelity, WYSIWYG rendering
  • Supports DOC, DOCX, PPT, PPTX, XLS, XLSX, ODF document format
  • Import and view Visio, Publisher and 100+ more
  • Shared Editing

Collabora is a big contributor to the LibreOffice project. All of the Collabora Online codes will be eventually included in LibreOffice.

Note: This tutorial works on Ubuntu 20.04, 18.04 and 16.04. If you are using another Ubuntu version, you can install Collobaora Online with Docker.

collabora online nextcloud server

Prerequisites

It’s assumed that you have already set up a Nextcloud server, which can be on any Linux distribution. If you haven’t already done so, then you can check out the following easy-to-understand guides.

The Collabora Online server and Nextcloud server can be on the same machine or on two different machines. This tutorial shows how to install Collabora online server on Ubuntu using a Docker image built by Collabora and Nextcloud. Then integrate it with an existing Nextcloud server.

Step 1: Install Collabora Online on Ubuntu From the Official Repository

Collabora has an official package repository for Ubuntu 20.04, 18.04 and 16.04. Run the following command to add it to your Ubuntu system.

Ubuntu 20.04

echo 'deb https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-ubuntu2004 ./' | sudo tee /etc/apt/sources.list.d/collabora.list

Ubuntu 18.04

echo 'deb https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-ubuntu1804 ./' | sudo tee /etc/apt/sources.list.d/collabora.list

Ubuntu 16.04

echo 'deb https://www.collaboraoffice.com/repos/CollaboraOnline/CODE ./' | sudo tee /etc/apt/sources.list.d/collabora.list

Then run the following command to download and import Collabora public key, which allows APT package manager to verify the integrity of packages downloaded from this repository.

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D

Since this repository uses HTTPS connection, we need to install the apt-transport-https and ca-certificates package, so the APT package manager can establish secure connection to the repository.

sudo apt install apt-transport-https ca-certificates

Now update local package index and install Collabora Online. Loolwsd is the LibreOffice Online WebSocket Daemon.

sudo apt update
sudo apt install loolwsd code-brand

Step 2: Configure LibreOffice Online WebSocket Daemon

After they are installed, you can check the status of loolwsd.

systemctl status loolwsd

LibreOffice Online WebSocket Daemon

Hint: If the above command didn’t quit immediately, you can press the Q key to make it quit.

As you can see, it failed to start. We can check journal to see why this happened.

sudo journalctl -eu loolwsd

Sample output:

Apr 21 16:13:06 ubuntu loolwsd[13842]: File not found: /etc/loolwsd/ca-chain.cert.pem
Apr 21 16:13:06 ubuntu systemd[1]: loolwsd.service: Main process exited, code=exited, status
Apr 21 16:13:06 ubuntu systemd[1]: loolwsd.service: Failed with result 'exit-code'.
Apr 21 16:13:07 ubuntu systemd[1]: loolwsd.service: Service hold-off time over, scheduling r
Apr 21 16:13:07 ubuntu systemd[1]: loolwsd.service: Scheduled restart job, restart counter i
Apr 21 16:13:07 ubuntu systemd[1]: Stopped LibreOffice Online WebSocket Daemon.
Apr 21 16:13:07 ubuntu systemd[1]: loolwsd.service: Start request repeated too quickly.
Apr 21 16:13:07 ubuntu systemd[1]: loolwsd.service: Failed with result 'exit-code'.
Apr 21 16:13:07 ubuntu systemd[1]: Failed to start LibreOffice Online WebSocket Daemon.

By default, loolwsd enables TLS connection. However, it didn’t find a TLS certificate file, hence the start failure. It’s better to disable TLS in loolwsd and terminate TLS at a reverse proxy. The loolwsd configuration file is located at /etc/loolwsd/loolwsd.xml. However, it’s an XML file, which is not easy to read and edit. We can use the loolconfig tool to change configurations.

Run the following command to disable TLS in loolwsd.

sudo loolconfig set ssl.enable false

And enable TLS termination at the reverse proxy.

sudo loolconfig set ssl.termination true

By default, loolwsd only allows known hosts to access its service. To allow Nextcloud to access the service, run the following command to add your Nextcloud hostname to the whitelist.

sudo loolconfig set storage.wopi.host nextcloud.example.com

You can also enable the admin account for loolwsd with the following command. You will need to set a username and password for the admin account.

sudo loolconfig set-admin-password

Restart loolwsd for the changes to take effect.

sudo systemctl restart loolwsd

Now it should be running without errors.

systemctl status loolwsd

Output:

systemctl status loolwsd

Step 3: Set up Reverse Proxy

Nextcloud server requires a TLS certificate on the Collabora Online, so we will need to create a virtual host, give the virtual host a domain name, set up a reverse proxy and install TLS certificate. We can use either Apache or Nginx to achieve this.

Apache

Install Apache web server with the following command:

sudo apt install apache2

Run the following command to create an Apache virtual host file for Collabora Online.

sudo nano /etc/apache2/sites-available/collabora.conf

Put the following text into the file. Replace the domain name with your actual domain name for Collabora Online. Don’t forget to create an A record for this sub-domain.

<VirtualHost *:80>
  ServerName collabora.example.com
  Options -Indexes

  ErrorLog "/var/log/apache2/collabora_error"
  # Encoded slashes need to be allowed
  AllowEncodedSlashes NoDecode

  # keep the host
  ProxyPreserveHost On

  # static html, js, images, etc. served from loolwsd
  # loleaflet is the client part of Collabora Online
  ProxyPass           /loleaflet http://127.0.0.1:9980/loleaflet retry=0
  ProxyPassReverse    /loleaflet http://127.0.0.1:9980/loleaflet

  # WOPI discovery URL
  ProxyPass           /hosting/discovery http://127.0.0.1:9980/hosting/discovery retry=0
  ProxyPassReverse    /hosting/discovery http://127.0.0.1:9980/hosting/discovery

  # Capabilities
  ProxyPass           /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities retry=0
  ProxyPassReverse    /hosting/capabilities http://127.0.0.1:9980/hosting/capabilities

  # Main websocket
  ProxyPassMatch "/lool/(.*)/ws$" ws://127.0.0.1:9980/lool/$1/ws nocanon

  # Admin Console websocket
  ProxyPass   /lool/adminws ws://127.0.0.1:9980/lool/adminws

  # Download as, Fullscreen presentation and Image upload operations
  ProxyPass           /lool http://127.0.0.1:9980/lool
  ProxyPassReverse    /lool http://127.0.0.1:9980/lool

</VirtualHost>

Save and close the file. To be able to proxy traffic using Apache, we need to enable some Apache modules.

sudo a2enmod proxy proxy_wstunnel proxy_http

Enable this virtual host with the following command:

sudo a2ensite collabora.conf

Then restart Apache.

sudo systemctl restart apache2

Nginx

Install Nginx on Ubuntu with the following command:

sudo apt install nginx

Create a virtual host file for Collabora Online.

sudo nano /etc/nginx/conf.d/collabora.conf

Put the following text into the file. Replace the domain name with your actual domain name for Collabora Online. Don’t forget to create an A record for this domain name.

server {
    listen 80;
    listen [::]:80;
    server_name  collabora.example.com;

    error_log /var/log/nginx/collabora.error;

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

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

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

    # main websocket
    location ~ ^/lool/(.*)/ws$ {
        proxy_pass http://localhost: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 ~ ^/lool {
        proxy_pass http://localhost:9980;
        proxy_set_header Host $http_host;
    }

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

Save and close the file. Then test Nginx configurations.

sudo nginx -t

If the test is successful, reload Nginx server.

sudo systemctl reload nginx

Step 4: Obtain and Install TLS Certificate

Now let’s obtain a free TLS certificate from Let’s encrypt. Run the following commands to install Let’s Encrypt client (certbot) from the default software repository.

sudo apt install certbot

If you use Apache web server, then you also need to install the Certbot Apache plugin.

sudo apt install python3-certbot-apache

Then issue the following command to obtain a free TLS/SSL certificate.

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d collabora.example.com

If you use Nginx web server, then you need to install the Certbot Nginx plugin.

sudo apt install python3-certbot-nginx

Then use the Nginx plugin to obtain and install the certificate by running the following command.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email you@example.com -d collabora.example.com

You will see the following text indicating that you have successfully obtained a TLS certificate.

collabora nginx reverse proxy https

Final Step: Connect Nextcloud to Collabora Online

In your Nextcloud dashboard, go to the Apps page. Next, go to Office & Text section, find the Collabora Online app, click Download and Enable button.

(Note: There’s another app called Collabora Online - Built-in CODE server, which you shouldn’t install on your Nextcloud server.)

collabora nextcloud setup

After this apps is enabled, go to Nextcloud Settings page. Click Collabora Online tab on the left. By default, it uses the built-in CODE server, which is not suitable for production use. We need to select Use your own server and enter the domain name of your Collabora Online including https:// prefix, then click Save button.

collabora online nextcloud integration docker

In the advance settings, you can also set OOXML as the default format, so the files will be compatible with Microsoft Office software.

office open xml format collabora

Now when you click the add button (+) in Nextcloud, you will be able to create Word, spreadsheet and presentation documents right from your Nextcloud server.

nextcloud online office

collabora online development edition nextcloud integration

The loolwsd admin console is available at https://collabora.example.com/loleaflet/dist/admin/admin.html. You need to enter the username and password, which was created at step 2.

loolwsd admin console

Troubleshooting

If Nextcloud tells you that it could not establish connection to the Collabora Online server, it might be that your Nginx server is running behind a reverse proxy like HAProxy and you have the following two lines in the /etc/nginx/nginx.conf.

set_real_ip_from 127.0.0.1;
real_ip_header proxy_protocol;

This means that Nginx expect HTTP connection from the reverse proxy. You should edit the /etc/nginx/conf.d/collaboara.conf file and add proxy_protocol to the listen directive.

listen 127.0.0.1:443 ssl http2 proxy_protocol;

Then edit the /etc/hosts file and add a static DNS record like below. Repalce 12.34.56.78 with the public IP address of the server.

12.34.56.78          collaboara.example.com

collabora.example.com should be pointed to the public IP address of your server. Don’t point it to 127.0.0.1.

You can also check the logs of loolwsd to find clues. Perhaps it’s not running.

sudo journalctl -eu loolwsd

And check the logs of web server.

  • Apache: /var/log/apache2/collabora_error
  • Nginx: /var/log/nginx/collabora.error

Wrapping Up

That’s it! I hope this tutorial helped you install, run Collabora Online on Ubuntu and integrate it with Nextcloud. As always, if you found this post useful, then subscribe to our free newsletter. You can also follow us on Twitter or like our Facebook page.

Rate this tutorial
[Total: 2 Average: 5]

21 Responses to “Integrate Collabora Online with Nextcloud on Ubuntu without Docker

  • That is so cool, thank you for sharing that!

  • Works perfectly! Thank you!

  • Hi Linuxbabe

    Thanks for the info.

    Do you have a config to install nextcloud and Collabora office on the same server, with no docker.

    Tx in Advance

    Johan

    • This article is for integrating Nextcloud and Collabora without Docker and it works when Nextcloud and Collabora run on the same server.

      • Hi Xiao Guoan and firstly thanks for your guide.
        I would ask you if is it possibile to show the Letsencrypt enabled virtualhost config content.

        Thanks again!

        Davide

  • Quang Mai
    8 months ago

    Hi Xiao,

    Thanks for this article instruction. I have a question about integrating Nextcloud and Collabora run on the same server.
    Let’s say I have 1 static IP at AWS Lightsail: 111.222.333.444 points to cloud.domain.com.
    So if we install Collabora on the same server which means 111.222.333.444, how do we set up the A record for DNS which will point collabora.domain.com to the same IP address: 111.222.333.444? Is there any conflict between these?

    Once again, thank you very much for this.
    Kind regards,
    Quang

    • No. There won’t be any conflict.

      • Quang Mai
        8 months ago

        Hi Xiao,

        Thanks for the reply. I followed along and tried to install nextcloud and collabora online with the same server as your guidance.

        Unfortunately, I have had an issue at the very last step when I installed and activated the TLS certificate with Nginx.

        The error as like this:

        Failed authorization procedure. collabora.example.com (http-01): urn:ietf:params:acme:error:dns :: No valid IP addresses found for collabora.example.com
        
        IMPORTANT NOTES:
         - The following errors were reported by the server:
        
           Domain: collabora.example.com
           Type:   None
           Detail: No valid IP addresses found for collabora.example.com

        I already checked the Whatmydns for both cloud.example.com and collabora.example.com. They both point to the same IP address correctly as expected.
        Do you have a solution for this case, please?
        Thank you very much.
        Regards,
        Quang

  • Hi,

    I’ve got Nextcloud 18.0.6 and the last version (4.2.4) of Collabora – CODE running on the same server and it really works fine.

    Nevertheless, there is only the english dictionary installed. Can you tell me how to install another dictionary ?

    Thanks for your help.

    Freddy

    • Francesc Ortiz
      7 months ago

      I have the same problem, I need to install another lenguage, but I try differents ways and tutorials and nothing happened, always show english dict. alone.

  • Andrew Wilson
    7 months ago

    Totally AWESOME instructions. Worked first time!

    I set this up in an lxc ubuntu 18.04 container running on an ubuntu 20.04 server. It connected with my lxc Nextcloud container (running on the same server). I setup my domain names, run the certbot, fixed a type (my bad…) and it just WORKED!

    You are friggin AWESOME!!! Thank you very much. 🙂

  • Muqtadir Kamal
    6 months ago

    Hi,
    I already i was installed locally system, i don’t have and DNS name, i m using oracle vm virtualbox , everything i was install successfully only stack in edit online doucment “Integrate Collabora Online” , what i have to enter ? “Use you own server URL (and Port) of Collabora Online-server” and i am able open the “Collabora Online admin panal” “loleaflet/dist/admin/admin.html”

    Kindly help this regards

    • Nextcloud requires you to use https connection with Collabora. If you don’t have a DNS name, you can just use LibreOffice on your Linux desktop, and don’t use Collabora Online.

      I would recommend buying a domain name (which can be as low as $1.37/year), if you really want to tinker with server software

  • Thanks for the great tutorial – what would I have to change if I installed Collabora and Nextcloud on 2 different hosts?
    The admin interface of Collabora already answers me externally.
    I use different external addresses for Nextcloud and Collabora 2.
    The Collabora service works too! The Request: https://localhost:8890 – gives the answer: OK
    After adding it to Nextcloud, I get the error: “Could not connect to the Collabora Online server.”I think a problem with the proxy?

  • Thank you very much, this also worked on an Ubuntu 20.04 server with already installed Nextcloud.
    In NextCloud, when I click on + and Document with name TestDocument, I get a progress bar at 0% and the text “connecting…”.
    It will timeout later with an error message.
    Now when I go back to the Folder view in NextCloud, I can see the document “TestDocument”.
    When I (as admin or user) click on this document, I am in the Collabora Text Processor, everything is fine now. I can edit the document, save and reopen.
    So everything works, only the initial document creation times out.

    In the nextcloud.error log I see the “client denied” message though:

    [Thu Sep 03 10:25:28.251889 2020] [access_compat:error] [pid 10490] [client 123.45.67.89:18655] AH01797: client denied by server configuration: /var/www/nextcloud/data/.ocdata

    This .ocdata file is empty.

  • ThumbOne
    4 months ago

    Thanks for this brilliant guide. I love it! I have Nexcloud and Collabora on the one box now. But it doesn’t work.

    When I point Nextcloud to the Collabora URL under: URL (and Port) of Collabora Online-server as you have and click Save it reports “Could not establish connection to the Collabora Online server.”

    I see nothing in the Nextcloud log. So what I’m wondering is how, further to diagnose this. I tried simply testing some of he configured URLS. For example on the WPI discovery URL, I do see a beautiful page which lets me discover the WOPI services. Nice. It’s a rich JS driven page. On the WOPI capabilities URL, I get lovely terse response which renders in raw format as: {“convert-to”:{“available”:true},”hasMobileSupport”:true,”hasProxyPrefix”:false,”hasTemplateSaveAs”:false,”hasTemplateSource”:true,”productName”:”Collabora Online Development Edition”,”productVersion”:”4.2.6″,”productVersionHash”:”ed4f732″}.

    On the Admin console URL alas I get no response, the browser just sits and whirs waiting. That is not encouraging.

    I am wondering what does Nextcloud test to see that the server is active? And what diagnostic tips might you provide? Be mighty appreciative for any tips.

    What do you see if you navigate to https:collaboraserver.tld/lool/adminws? I don’t get a response alas. And would love to know if I should expect one and if so, what and how to diagnose why its not there.

    There is but one subtle difference between all the web server configs listed, they all reverse proxy to localhost:9980, but the admin console and main websocket have an Upgrade header set. I wonder if something there went wrong and how to find out if it did. I use lighttpd, and its mod_proxy: https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModProxy, it’s comparable syntax seems to be proxy.header = ( “upgrade” => “enable” ).

    The trick is understanding what this upgrade command does in Apache, and in Nginx.

  • My ubuntu 20 LTS installation required the command
    ”’wget https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-centos7/repodata/repomd.xml.key && sudo apt-key add repomd.xml.key”’
    in order to pull down the key

  • Thanks for the great tutorial. I already i was installed locally system, i don’t have and DNS name, i m using oracle vm virtualbox , everything i was install successfully only stack in edit online doucment “Integrate Collabora Online” , but when i edit doc files, always like this, hopefully i have the solutions from here

  • I got to the end of Step 1: sudo apt update && sudo apt install loolwsd code-brand

    I received the following error: E: Package ‘loolwsd’ has no installation candidate

    A cursory search found a reference that said “Collabora doesn’t support ARM platforms…”.

    I’m trying to do this on an RPi 4 8G 64bit with LAMP stack and Nextcloud 20.0x. Does this mean I’m stuck doing it with Docker? The last time I tried that it crashed my server, so I was excited to see your tutorial on how to do it without Docker.

  • Rashmi
    1 week ago

    Hi, I have installed nextcloud with LAMP stack on ubuntu 20.04 on LXC container in Proxmox. Nextcloud is working great using haproxy under Pfsense but I cannot get Collabora to work using Apache. I saw you post if I installed it using nginx, should I delete apache to install nginx?

    Is there a way to get apache to work using haproxy also, if so how?

    Thanks

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image.