sodcalculator

10 Tech How-To

Install Nextcloud with OnlyOffice on Ubuntu

Guide 10-35670 · Updated · Step by step

To install Nextcloud with OnlyOffice integration on Ubuntu, you need to set up Nextcloud, install Docker and the OnlyOffice Document Server, then connect them using the OnlyOffice connector app. This guide walks through the entire process on a fresh Ubuntu 22.04 or 24.04 server, assuming you have a domain name and basic command-line comfort.

What You Need Before Starting

OnlyOffice Document Server is a heavy piece of software. It runs best in Docker, and it needs a separate subdomain (like office.example.com) because the integration requires HTTPS and a distinct origin. You also need:

  • A Ubuntu server with at least 4 GB RAM and 2 CPU cores (8 GB RAM is safer if you expect multiple editors open at once).
  • A domain name pointing to your server (A record for nextcloud.example.com and another for office.example.com).
  • Ports 80 and 443 open in your firewall.
  • Nextcloud already installed, either via Snap, manual LAMP/LEMP, or the official Nextcloud VM script.

If you do not have a domain, you can use a self-signed certificate, but browsers will warn, and mobile apps may refuse to connect. A free Let’s Encrypt certificate is the standard solution.

Install Docker and OnlyOffice Document Server

OnlyOffice provides an official Docker image that bundles the document server. First, install Docker if it is not already present:

  1. sudo apt update && sudo apt install docker.io docker-compose
  2. Enable and start Docker: sudo systemctl enable --now docker
  3. Create a directory for OnlyOffice data: sudo mkdir -p /opt/onlyoffice
  4. Run the container (replace office.example.com with your real subdomain):
sudo docker run -i -t -d -p 80:80 -p 443:443 \
  -v /opt/onlyoffice/Data:/var/www/onlyoffice/Data \
  -v /opt/onlyoffice/Logs:/var/log/onlyoffice \
  -v /opt/onlyoffice/cache:/var/lib/onlyoffice \
  -v /opt/onlyoffice/db:/var/lib/postgresql \
  -e JWT_ENABLED=true \
  -e JWT_SECRET=your-random-secret-here \
  --restart always \
  onlyoffice/documentserver

This starts OnlyOffice on ports 80 and 443. If your Nextcloud is already using those ports, you must change the host port mapping (e.g., -p 8080:80) and later configure a reverse proxy. For simplicity, this guide assumes a fresh setup where OnlyOffice gets 80/443 directly and Nextcloud is on a different port or behind a proxy.

Set Up HTTPS with Let’s Encrypt

OnlyOffice requires HTTPS to work with Nextcloud (even if Nextcloud is on HTTP, the connector expects a secure origin). Use Certbot to obtain a certificate:

  1. Install Certbot: sudo apt install certbot
  2. Stop the OnlyOffice container temporarily: sudo docker stop onlyoffice/documentserver (or use the container name/ID).
  3. Run sudo certbot certonly --standalone -d office.example.com
  4. Restart the container: sudo docker start <container-id>
  5. Set up a cron job to renew the certificate automatically: sudo crontab -e and add 0 3 * * * certbot renew --quiet --deploy-hook "docker restart <container-id>"

If you are using a reverse proxy (like Nginx) in front of OnlyOffice, you would obtain the certificate for that proxy instead. The key point is that the Document Server must be reachable via HTTPS.

Install the OnlyOffice Connector in Nextcloud

Once OnlyOffice is running, you need to install the connector app in Nextcloud. There are two ways:

  • From the Nextcloud app store: Go to Apps → Office & text → OnlyOffice, and click Enable.
  • Manual installation: Download the latest onlyoffice.tar.gz from the Nextcloud apps repository, extract it into /var/www/nextcloud/apps/ (or your custom apps path), then enable it via occ command: sudo -u www-data php occ app:enable onlyoffice.

After enabling, go to Nextcloud Settings → OnlyOffice. Enter the Document Server URL: https://office.example.com. Leave the secret field empty unless you set a JWT secret in the Docker run command. If you did set JWT_SECRET, enter that same value in the “Secret key” field. Save the settings.

Verify the Integration and Troubleshoot Common Issues

Create a new document in Nextcloud (click the + icon → New document). It should open in an OnlyOffice editor within the Nextcloud interface. If it does not, check the following:

  • Mixed content: If Nextcloud is on HTTP and OnlyOffice on HTTPS, the browser blocks the iframe. Ensure both are HTTPS.
  • JWT mismatch: If you enabled JWT in OnlyOffice but left the secret blank in Nextcloud, you will see a “JWT verification failed” error. Set the same secret in both.
  • Firewall: Ensure ports 80 and 443 are open on the OnlyOffice server. Test with curl -I https://office.example.com from the Nextcloud server.
  • DNS: Confirm the subdomain resolves to the correct IP. A quick dig office.example.com helps.
  • Docker logs: Inspect logs with sudo docker logs <container-id> to see errors.

A common misconception is that OnlyOffice is a lightweight plugin. It is actually a full document server with its own database (PostgreSQL) and Redis cache. It consumes significant RAM, especially when multiple users edit simultaneously. If your server is low on memory, consider upgrading or limiting concurrent editing sessions.

Performance and Security Considerations

OnlyOffice Document Server is a resource-hungry service. For a small team (1-5 users), 4 GB RAM may suffice, but for heavier use, 8 GB is recommended. You can monitor usage with htop or docker stats.

Security-wise, the JWT secret is crucial. It prevents unauthorized access to the document server. Generate a strong random string using openssl rand -base64 32 and use it in both the Docker command and Nextcloud settings. Also, keep the document server updated by pulling the latest Docker image periodically: sudo docker pull onlyoffice/documentserver and recreate the container.

If you are using a reverse proxy (like Nginx or Caddy) to manage SSL certificates for both Nextcloud and OnlyOffice, you need to configure the proxy to forward WebSocket connections for OnlyOffice. The official OnlyOffice documentation provides sample Nginx configurations. The key is to enable proxy_set_header Upgrade $http_upgrade and Connection "upgrade" for the /websocket path.

Alternatives and When to Use Them

OnlyOffice is not the only collaborative editing solution for Nextcloud. The main alternatives are:

  • Collabora Online (CODE): A LibreOffice-based editor that integrates well with Nextcloud. It is also resource-heavy but offers a different user interface. Some users find it more compatible with complex ODF documents.
  • Microsoft Office Online: Available only for Nextcloud Enterprise (paid). It requires a Microsoft 365 subscription.
  • Google Docs editing: Not a native integration; you can connect via third-party apps, but it is clunky.

Choose OnlyOffice if you want a free, open-source solution that handles Microsoft Office formats (docx, xlsx, pptx) with high fidelity. Choose Collabora if you prefer a LibreOffice-based experience or if you already use LibreOffice in your workflow. OnlyOffice tends to have better compatibility with complex Word documents, while Collabora is stronger with Calc spreadsheets in some scenarios.

Frequently Asked Questions

Can I install OnlyOffice without Docker?

Yes, but it is more complex. OnlyOffice provides .deb packages and installation scripts for Ubuntu, but they require manual configuration of PostgreSQL, RabbitMQ, and Nginx. Docker is the recommended and supported method because it bundles all dependencies and simplifies upgrades.

Do I need a separate domain for OnlyOffice?

Technically no, but it is highly recommended. The integration requires a different origin to avoid cookie conflicts. You can use a subdomain like office.example.com or a different port (e.g., https://example.com:8443), but a subdomain is the cleanest and most reliable.

Why does my document not save back to Nextcloud?

This usually happens when the JWT secret is mismatched or the document server cannot reach Nextcloud. Check that the Nextcloud server is accessible from the OnlyOffice container (try curl from inside the container) and that the secret is identical in both places.

Can I use OnlyOffice with a Nextcloud Snap installation?

Yes. The Snap version of Nextcloud includes its own Apache and PHP. You install the OnlyOffice connector via the Snap’s app store or by placing the app in the Snap’s apps directory. The process is similar, but you need to use sudo nextcloud.occ to run occ commands.

Is OnlyOffice free for commercial use?

Yes, the Community Edition of OnlyOffice Document Server is free and open source (AGPLv3). You can use it in a commercial environment without paying, as long as you comply with the license terms (e.g., providing source code if you distribute modified versions).

How do I update OnlyOffice Document Server?

Pull the latest Docker image, stop the old container, remove it, and run a new one with the same volume mounts. Your data persists because it is stored in the mounted directories. Check the release notes for any breaking changes before upgrading.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →