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.
- How to Install Nextcloud on Ubuntu 20.04 with LEMP Stack
- How to Install Nextcloud on CentOS 8 with LEMP Stack
- How to set up Nextcloud on Arch Linux
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
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
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
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
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.
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.)
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.
In the advance settings
, you can also set OOXML as the default format, so the files will be compatible with Microsoft Office software.
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.
Troubleshooting Tips
If Nextcloud tells you that it c
ou 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.
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;
How to Upgrade Collabora Online Docker
To upgrade to the latest version, all you need to do is to pull the latest image from Docker hub and restart the container. Here’s how.
First, log into your server and pull down the latest collabora/code
image by running the following command.
sudo docker pull collabora/code:latest
The command will download the intermediate image layer between the existing image on your host and the latest image on Docker hub. Once the download is complete, there will be two collabora/code images with different tags identifying the version.
sudo docker images
Output:
REPOSITORY TAG IMAGE ID CREATED SIZE collabora/code latest 499f29f2703e 2 weeks ago 1.75 GB collabora/code <none> 05a1b4c2d8db 5 weeks ago 1.129 GB
Next, list running containers
sudo docker ps
Then stop and remove the running collabora/code
container. The container-id
can be obtained from sudo docker ps
command.
sudo docker stop container-id sudo docker rm container-id
Now run a new container from the latest collabora/code
image. Replace nextcloud\\.your-domain\\.com
with the domain name of your Nextcloud server.
sudo docker run -t -d -p 127.0.0.1:9980:9980 -e 'domain=nextcloud\\.your-domain\\.com' --restart always --cap-add MKNOD collabora/code
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.
Thank you for creating this. Excellent instructions. 🙂
Thank you for you tutorial. When activating nginx, I encounter this message.
root@***:~# sudo systemctl reload nginx
nginx.service is not active, cannot reload.
root@***:~# 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.
root@***~# sudo systemctl reload nginx
nginx.service is not active, cannot reload.
root@***:~# 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?
Check out the log to see what caused this problem.
or
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?
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
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.
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
(replacing domain name preserving double slashes) and then
I have no output.
I opened 9980 TCP port on UFW (
).
If I try
in STATUS I always read “Restarting (1) **number** seconds ago”.
What’s wrong?
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?
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
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.i have my cert issued. and :
jose@dul:~$ 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.
Check the logs of web server:
Apache: /var/log/apache2/collabora_error
Nginx: /var/log/nginx/collabora.error
thanks for your reply, i already fix the problem.
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.
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.
I can’t open new create file error.
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
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?
sorry here is there error
“\n\n\t<head\n data-requesttoken=\"mk9C"
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
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
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
I’ve attempted to use nginx, which I’m more familiar with, and apache2. All I see on the page is the default apache or nginx webpage. I believe I should get into the admin page for collabora.
Additionally I cannot get the server to connect in nextcloud. I don’t know what I’m doing wrong, can anyone help out?
Getting the following message when trying to create a file and edit it on the Nextcloud server:
“Failed to load Collabora Online Development Edition – please try again later”
Any thoughts?
Hi,
many thanks for your work. It looks nice, but it doesn’t work for me. I thought, I did all steps of your howto (with nginx) exactly. I can add in my nextcloud server the collabora app and connect to my collabora server.
But when I try to open a document, my nextcloud server tries to connect to my collabora server and in my browser I get the message “404 not found” instead of the opened document.
In the nginx logs I read:
I use Nextcloud 20.0.5 installed and hosted by all-inkl.com with Collabora Online 3.8.6. The collabora server runs on the smallest virtual server by hetzner.com with ubuntu 20.04. If I use a demoserver instead of my own server, everything works fine.
Does anybody has a hint for me?
Thanks.
Sorry, the logs are not complete, second attempt without HTML tag:
==> /var/log/nginx/access.log /var/log/nginx/collabora.error /var/log/nginx/access.log <==
my.collabora.server.ip – – [28/Dec/2021:17:30:39 +0000] "POST /browser/1e92cc5/cool.html?WOPISrc=https%3A%2F%2Fmy%2Fnc%2Findex.php%2Fapps%2Frichdocuments%2Fwopi%2Ffiles%2F7685_ocwa5i2784pj&title=1qjw9pqasxx0.ods&lang=de&closebutton=1&revisionhistory=1 HTTP/1.1" 404 197 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4736.0 Safari/537.36"
It seems, that your system cuts my logs. Third attempt with an image:
I found a solution:
The in this site described configuration of the nginx reverse proxy doesn’t work with an actual collabora docker image.
I read this page
https://sdk.collaboraonline.com/docs/installation/Proxy_settings.html#reverse-proxy-with-nginx-webserver
and adapted a few points in the file /etc/nginx/conf.d/collabora.conf
localhost -> 127.0.0.1
loleaflet -> browser
lool -> cool (at section main websocket and Admin Console websocket)
lool -> (c|l)ool (at section download, presentation … )
Now every works perfectly.
Could you send a pic of your config, I’m trying to install it in my nextcloud as all of you and I can’t make it work, ill trie the changes that you suggest and answer this
Your tip helped me a lot and solved all my problems. Thank you very much!
This is my collabora.conf file (hostname chaned to MY.SERVER.DOMAIN) that works for me.
I forgot to delete the lines 50/51. Due to security reasons I don’t run my collabora server on the standard port …
Thanks Linux Babe.
I’ve setup docker/collabora in the past a few times and have always seemed to have issues. I did a simple copy & paste from your instructions and everything worked.
I’ve tried these instructions on both a host on my LAN and a Linode instance. In both cases, I can create .odt files, but not edit them. I can create and edit text files “*.md”
When I use a demo server, all works fine.
I’m using Nextcloud Hub 3 (25.0.3)