How to run Collabora office for Nextcloud using docker-compose
Create this docker-compose.yml
, e.g. in /opt/collabora-mydomain
:
services:
code:
image: collabora/code:latest
restart: always
environment:
- password=${COLLABORA_PASSWORD}
- username=${COLLABORA_USERNAME}
- aliasgroup1=https://collabora.mydomain.com:443
- aliasgroup2=https://nextcloud.myseconddomain.com:443
- server_name=collabora.mydomain.com
- extra_params=--o:ssl.enable=true
ports:
- 9980:9980
labels:
- "traefik.enable=true"
- "traefik.http.routers.collabora.rule=Host(`collabora.mydomain.com`)"
- "traefik.http.routers.collabora.entrypoints=websecure"
- "traefik.http.routers.collabora.tls.certresolver=cloudflare"
- "traefik.http.routers.collabora.tls.domains[0].main=mydomain.com"
- "traefik.http.routers.collabora.tls.domains[0].sans=*.mydomain.com"
- "traefik.http.services.collabora.loadbalancer.server.port=9980"
- "traefik.http.services.collabora.loadbalancer.server.scheme=https"
If required, add more aliasgroups as needed.
Now create this .env
with the configuration. You need to change the password and the domain!
COLLABORA_USERNAME=admin
COLLABORA_PASSWORD=veecheit0Phophiesh1fahPah0Wue3
Now you can create a systemd service to autostart by using our script from Create a systemd service for your docker-compose project in 10 seconds.
Run from inside your directory (e.g. /opt/collabora-mydomain
)
curl -fsSL https://techoverflow.net/scripts/create-docker-compose-service.sh | sudo bash /dev/stdin
Traefik config
All relevant traefik config is already in the docker-compose.yml
. You need to have Traefik running and configured to use the cloudflare
certresolver.
See this TechOverflow post for the Traefik configuration we’re using.
nginx config.
Note: I generally recommend using Traefik.
Now you need to configure your reverse proxy to point to port 9980
. Here’s an example nginx
config:
server {
server_name collabora.mydomain.com;
access_log /var/log/nginx/collabora.mydomain.com.access_log;
error_log /var/log/nginx/collabora.mydomain.com.error_log info;
location / {
proxy_pass https://127.0.0.1:9980;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
add_header X-Frontend-Host $host;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}
listen [::]:80; # managed by Certbot
}
Now open your browser and open collabora.mydomain.com
. If collabora is running correctly, you should see:
OK
In Nextcloud, goto https://nextcloud.mydomain.com/settings/admin/richdocuments
and set the URL (and Port) of Collabora Online-server to:
https://admin:[email protected]
Ensure to use your custom password from .env
and your custom domain!
Click Save and you should see Collabora Online server is reachable
: