Integrate Collabora Online with Nextcloud on Ubuntu with Docker

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

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: If you are using Ubuntu 16.04 or Ubuntu 18.04, you can install Collabora Online from the official package repository, which is easier to manage than using Docker.

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 Docker on Ubuntu

If you want the latest Docker version, you can install Docker from Docker’s APT repository. For simplicity, this tutorial installs Docker from the default Ubuntu software repository.

sudo apt update
sudo apt install docker.io

Once installed, the Docker daemon should be automatically started. You can check its status with:

systemctl status docker

systemctl status docker

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

If it’s not running, then start the daemon with this command:

sudo systemctl start docker

And enable autostart at boot time:

sudo systemctl enable docker

Step 2: Install and Run Collabora Online Server with Docker

Execute the following command to pull the latest Collabora Online Development Edition image from Docker hub.

sudo docker pull collabora/code

collabora online docker image

Then run this docker container with the following command. Replace nextcloud\\.example\\.com with your Nextcloud hostname, preseving the double slashes. This is because Collabora only allows known hosts to access its service and we need to add the Nextcloud hostname to the whitelist with the domain= parameter.

sudo docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=nextcloud\\.example\\.com' -e "extra_params=--o:ssl.enable=false --o:ssl.termination=true" --restart always collabora/code

collabora online code

Where:

  • -d: Detached mode makes the container run in the background.
  • -t: Allocate a pseudo-TTY
  • -p: Publish a container’s port to the host.
  • -e: Set environment variables

The Collabora Online server will be listening on port 9980 of localhost (127.0.0.1) as can be shown by issuing the following command. (If your Ubuntu system doesn’t have the netstat command, you can install it with sudo apt install net-tools.)

sudo netstat -lnpt | grep docker

collabora online nextcloud docker

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 official certbot PPA.

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 [email protected] -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 [email protected] -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

Troubleshooting Tips

If Nextcloud tells you that it could not establish connection to the Collabora Online server, you can check if the Docker container is running.

sudo docker ps

And check the logs of web server.

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

You should also edit the /etc/hosts file and add a static DNS record like below. Replace 12.34.56.78 with the public IP address of the server.

12.34.56.78          collabora.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.

If 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 expects 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;

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: 43 Average: 4.3]

36 Responses to “Integrate Collabora Online with Nextcloud on Ubuntu with Docker

  • Thank you for creating this. Excellent instructions. 🙂

  • Thank you for you tutorial. When activating nginx, I encounter this message.

    [email protected]***:~# sudo systemctl reload nginx
    nginx.service is not active, cannot reload.
    [email protected]***:~# sudo systemctl start nginx
    Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.
    [email protected]***~# sudo systemctl reload nginx
    nginx.service is not active, cannot reload.
    [email protected]***:~# sudo systemctl status nginx.servic
    ● nginx.servic.service
    Loaded: not-found (Reason: No such file or directory)
    Active: inactive (dead)

    Why is this showing even though I installed nginx?

    • Xiao Guo-An (Admin)
      5 years ago

      Check out the log to see what caused this problem.

       sudo journalctl -xe

      or

       sudo less /var/log/nginx/error.log
      • Thank you for your quick answer.

        Here is what I get:

        Nov 19 11:15:04 vps338912 kernel: [UFW BLOCK] IN=ens3 OUT= MAC=fa:16:3e:1f:31:98:fe:01:d6:d5:05:4e:08:00 SRC=85.214.201.198 DST=51.254.120.238 LEN=60 TOS=0x00 PREC=0x00 TTL=55 ID=21

        2016/11/19 11:08:25 [emerg] 581#581: listen() to [::]:80, backlog 511 failed (98: Address already in use)
        2016/11/19 11:08:25 [emerg] 581#581: still could not bind()
        /var/log/nginx/error.log (END)

        I added Nginx on ufw (sudo ufw allow in “Nginx Full”), yet it does not seem to help. How can I allow Nginx traffic?

        • Xiao Guo-An (Admin)
          5 years ago
          listen() to [::]:80, backlog 511 failed (98: Address already in use)

          This line tells you that port 80 is already is use by another process, so Nginx can’t listen on port 80. Have you installed Apache on your server? If that’s so, then you may want to use Apache rather than Nginx to set up the reverse proxy.

        • Thank you. Of course, you are right.

  • A great tutorial. Thanks for it.

    But I have one question: How can I add new fonts?

    Have a nice day
    Dirk

  • ehrenman, ty bro

  • elrazumes
    1 year ago

    Hello, A very great tutorial. The whole series of tutorial regarding Nextcloud is great.
    However i have one question.
    Can i integrate collabora into nextcloud with the same machine but only for local machines?
    Sorry if its a stupid question, i am a beginner.

  • maximumwarp
    1 year ago

    Hello and thank you for this tutorial.
    I’ve problem running collabora on my Raspberry Pi 4 server with Ubuntu 20.04 LTS: when I do

    sudo docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=nextcloud\\.example\\.com' -e "extra_params=--o:ssl.enable=false --o:ssl.termination=true" --restart always collabora/code

    (replacing domain name preserving double slashes) and then

    sudo netstat -lnpt | grep docker

    I have no output.
    I opened 9980 TCP port on UFW (

    sudo ufw allow 9980\tcp

    ).
    If I try

    sudo docker ps

    in STATUS I always read “Restarting (1) **number** seconds ago”.

    What’s wrong?

    • maximumwarp
      1 year ago

      Ok, the problem is collabora/code Docker container doesn’t support ARM64 architecture… 🙁
      There is a way to install Collabora on Ubuntu 20.04 without Docker?

  • I cant get certbot to do its thing. I have the subdomain set up with an A record, can ping the server and it all works, but for some reason certbot refuses to install a certificate. Can someone please tell me whats going wrong?

    • Geoffrey
      5 months ago

      Run certbot with -a webroot and define the web root which is likely /var/www/html if using apache, you’ll also want to do -i apache instead of the ole –apache

  • Oliver Meyer
    10 months ago

    Hello, i have been following your tutorial until the very end. Everything is installed and seems running. I fetched the certificate and that worked fine also. The only problem i have us that the standard SSL port is already in use for another application that cannot be changed. So the Ubuntu server – docker – reverse proxy needs to be reconfigured to be able to operate.

    office.domain.yx:4433 would be my choice that could be forwarded through the router / firewall

    do i have to adapt in apache2 / collabora and…? And what would be the alterations?
    I had a look / changed at ports.conf …

  • Best tutorial on the web!!!

    no errors. Zero. Up and running in 35 mins.

    if you use nginx: don’t forgot to change apache to nginx when installing the cert. lol. terminal will tell you if you forget like i did.

    I love how the instructions explain what you are doing.

    ie
    -d: Detached mode makes the container run in the background.
    -t: Allocate a pseudo-TTY
    -p: Publish a container’s port to the host.
    -e: Set environment variables

    Thank you LinuxBabe

  • Dear LinuxBabe:

    when i go to “https://collabora.example.com” i see a webpage that says Welcome to Nginx! If you see this page, the nginx web server is successfully…..

    Nextcloud and Collabora Online work perfectly!!!!! Thank you!!!!!!

    How can I block the server webpage or put a simple blue screen index.html file somewhere?

    i was thinking something in /etc/nginx/conf.d/collabora.conf like your instructions from install Nextcloud, but don’t know what to write.

    Best regards

    • The Nginx default page (index.html) is located at /usr/share/nginx/html/index.html. You can edit this file and change its content to your liking.

  • Hi, I am installing a server w Lamp, NextCloud and Collabora w your tutorials. I’m new to Ubuntu server and did a few mistakes, it is my 3d installation… and letsencrypt won’t issue me a certificate for collabora (weekly limit exceeded).
    Is there an alternative? Can I rollback the install of collabora to at least have NextCloud working?
    Did you get my PayPal donation?
    Thank you in advance

    • Right now, you can’t obtain Let’s Encrypt certificate.

      Remove the /etc/apache2/sites-enabled/collabora.conf and /etc/apache2/sites-enabled/collabora-le-ssl.conf file. Then restart Apache.

      Wait several days. After the the weekly limit is lifted, you can create the /etc/apache2/sites-available/collabora.conf file again and use certbot to obtain certificate.

  • JOSE DELLA BOSCA
    9 months ago

    i have my cert issued. and :

    [email protected]:~$ sudo netstat -lnpt | grep docke
    tcp 0 0 127.0.0.1:9980 0.0.0.0:* LISTEN 179510/docker-proxy

    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    11b003c7ad0f collabora/code “/bin/sh -c ‘bash st…” 55 minutes ago Up 54 minutes 127.0.0.1:9980->9980/tcp naughty_keldysh

    but, i tried 127.0.0.1 (which connects) and i have this problem (see attachment)

    translation:
    The page 127.0.0.1 has refused the connection

    if i write
    https://collabora.dulkresa.dyndns.org it does not connect.

  • I am getting this error in nextcloud collabora setup “Could not establish connection to the Collabora Online server”.

    • and in collabora error log “Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:9980 (127.0.0.1) failed”

  • I got to the end of Step 2 and ran the netstat command with the -lnpt, but it gave no output. When I dropped the t, below is what I got.

    [email protected]:~$ sudo netstat -lnp | grep docker
    unix  2      [ ACC ]     STREAM     LISTENING     76042    1/init               /run/docker.sock
    unix  2      [ ACC ]     STREAM     LISTENING     76392    4672/dockerd         /var/run/docker/metrics.sock
    unix  2      [ ACC ]     STREAM     LISTENING     76429    4672/dockerd         /var/run/docker/libnetwork/eb148228fe4
    

    I kept going with the instructions, but got the dreaded “could not establish a connection message…” Is it a docker issue?

    I have a NC server installed on a RPi4 8G running Ubuntu 20.04 and LAMP stack.

  • Pyae Phyo Khine
    7 months ago

    I can’t open new create file error.

  • Geoffrey
    5 months ago

    I am having the i believe the same issue as above.

    In settings of nextcloud it establishes connection fine but when I actually go to edit a file I get the attached Collabora Refused to Connect error.

    I have installed using OEM method: https://nextcloud.com/collaboraonline/

    and this one all with the same outcome, It seems like maybe a known hosts issue on collabora end but im not sure how to check as I cannot find anything in logs

  • sharkbtye
    5 months ago

    everything worked great up until of course lets encrypt i receive this error when i go to encrypt

    “\n\n\t<head\n data-requesttoken=\"mk9C

    I have NC on raspberry pi 4 8gb and ubuntu 20.o4 on a second raspberry pi 3 b+ to see if collabora will run faster.
    I have NC on exampleNC.website.org and the collabora server on the secong pi at exampleoffice.website.org

    running NC 20.0.8 and also tried putting in the collabora site into nextcloud exampleoffice.website.org
    settings and connection is refused

    Ant idea how to fix this?

  • Hi,

    First of all, thanks for this tuto! worked like a charm!

    My situation is as follows. I share nextcloud with my wife and have the same installation for both of us, but each of us access with its own domain and both domain are in the trusted sites config.php

    I’ve installed collabora for my domain, but when she want to edit a document on her domain gets WOPI access error, that makes sense because when I run docker I use it only my domain, can I run it again with her domain as well? or I should seek for other solution

    Thanks for your help

  • dysonsphere
    3 months ago

    Ubuntu 20.04
    Nextcloud 21.0.1
    Apache 2.4.41 (Ubuntu)

    I have installed as instructed and am able to connect to my collabora server with the collabora settings.
    However, when I attempt to create or edit a document I get a notification window that says:
    “Unauthorized WOPI host. Please try again later and report to your administrator if the issue persists”.
    Has this come up for anybody else?
    Any ideas how to fix it?

    Thanks

  • dysonsphere
    3 months ago

    OK so there was a typo in my docker run statement 🙁

  • First, thank you! This was the only tutorial I could find to install collabora on my server. The directions on the collaboraoffice.org site are crazy lacking. That said, there’s one thing I can’t figure out, and perhaps it would be worth adding to the tutorial. I would love to be able to white list more than one instance of nextcloud to use the collabora server, i.e. nextcloud.example2.com However, I can’t figure out the syntax of adding a second, third, etc. domain when making this command:

    sudo docker run -t -d -p 127.0.0.1:9980:9980 -e ‘domain=nextcloud\\.example\\.com’ -e “extra_params=–o:ssl.enable=false –o:ssl.termination=true” –restart always collabora/code

    It seems the command can only be made once and the whitelist is declared only then.

    Any help, most welcome!

  • Followed the same all good but someone can share nginx code (nextcloud.conf) for this error
    There are some warnings regarding your setup.
    Your web server is not properly set up to resolve “/.well-known/webfinger”.
    Your web server is not properly set up to resolve “/.well-known/nodeinfo”.

    Thank you

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. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded.