keepcalculator

06 Numbers and Powers

Self-Host OnlyOffice on a VPS for Team Collaboration

Card No. 06·41294 · Updated · Standard formula, shown below

This guide walks you through installing and configuring OnlyOffice Document Server on your own VPS, so your team can collaborate on documents, spreadsheets, and presentations in real time without relying on third-party cloud services. You’ll end up with a private, self-hosted office suite that integrates with tools like Nextcloud or can be used standalone. Before starting, you’ll need a VPS with at least 4 GB of RAM (8 GB recommended), a domain name pointing to the server, and basic comfort with the command line.

What You’ll Need

  • A VPS running Ubuntu 22.04 or 24.04 (or Debian 11/12) with root or sudo access.
  • A domain name (e.g., office.example.com) with an A record pointing to your server’s IP.
  • Ports 80 and 443 open in your firewall.
  • At least 4 GB of RAM and 20 GB of free disk space.
  • Docker and Docker Compose installed (we’ll cover this).

Step-by-Step

  1. Update your system and install dependencies. SSH into your VPS and run sudo apt update && sudo apt upgrade -y. Then install basic tools: sudo apt install -y curl git nano.
  2. Install Docker and Docker Compose. Use the official convenience script: curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh. Verify with docker --version and docker compose version. If compose isn’t available, install it separately from the Docker docs.
  3. Create a directory for OnlyOffice. Run mkdir ~/onlyoffice && cd ~/onlyoffice to keep everything organized.
  4. Create a Docker Compose file. Use nano docker-compose.yml and paste the following minimal configuration:
    services:
      onlyoffice:
        image: onlyoffice/documentserver:latest
        container_name: onlyoffice
        ports:
          - "80:80"
          - "443:443"
        environment:
          - JWT_ENABLED=true
          - JWT_SECRET=your-super-secret-key
        volumes:
          - onlyoffice_data:/var/www/onlyoffice/Data
          - onlyoffice_logs:/var/log/onlyoffice
          - onlyoffice_cache:/var/lib/onlyoffice
          - onlyoffice_db:/var/lib/postgresql
        restart: unless-stopped
    
    volumes:
      onlyoffice_data:
      onlyoffice_logs:
      onlyoffice_cache:
      onlyoffice_db:
    

    Save with Ctrl+O, then Ctrl+X.

  5. Set a strong JWT secret. Replace your-super-secret-key with a long random string. You can generate one with openssl rand -base64 32.
  6. Start OnlyOffice. Run sudo docker compose up -d. The first pull may take a few minutes. Check logs with sudo docker compose logs -f until you see a message that the server is ready.
  7. Configure a reverse proxy with HTTPS. For production, don’t expose OnlyOffice directly. Install Nginx: sudo apt install -y nginx. Then create a site config: sudo nano /etc/nginx/sites-available/onlyoffice with a server block that proxies to http://localhost:80 and includes the proper headers. Enable it with a symlink and restart Nginx.
  8. Obtain an SSL certificate. Install Certbot: sudo apt install -y certbot python3-certbot-nginx. Run sudo certbot --nginx -d office.example.com and follow the prompts. This automatically configures HTTPS.
  9. Test the installation. Visit https://office.example.com in your browser. You should see the OnlyOffice welcome page. To verify functionality, create a test document using the built-in editor.
  10. Integrate with Nextcloud (optional but recommended). Install the OnlyOffice connector app in Nextcloud (via the app store). In Nextcloud admin settings, under OnlyOffice, enter your server URL and the JWT secret you set earlier. Now your team can open and edit documents directly from Nextcloud.
  11. Set up automatic updates. Add a cron job to pull new images and recreate the container weekly: sudo crontab -e and add 0 2 * * 0 cd ~/onlyoffice && docker compose pull && docker compose up -d.

Common Mistakes

  • Insufficient RAM. OnlyOffice is memory-hungry. With less than 4 GB, it may crash or fail to start. Check with free -h and consider adding swap.
  • Using HTTP for integration. Nextcloud and other clients require HTTPS. If you try to use a plain HTTP URL, the connection will be blocked.
  • Forgetting the JWT secret. If you integrate with Nextcloud and don’t set the same secret, document editing will fail with a JWT error.
  • Not opening ports. OnlyOffice needs ports 80 and 443 open. If you have a firewall (ufw), run sudo ufw allow 80,443/tcp.
  • Using the default secret. Leaving the JWT secret as “your-super-secret-key� is a security risk. Always change it.

Tips

  • For larger teams, increase VPS RAM to 8 GB or more. OnlyOffice uses about 2-4 GB under load.
  • Use a separate volume for database backups. The onlyoffice_db volume contains PostgreSQL data; back it up regularly.
  • If you plan to use OnlyOffice with Nextcloud, install the connector app on the same server to reduce latency.
  • Keep your JWT secret in a password manager. You’ll need it for every integration.
  • Consider setting up a firewall that only allows SSH, HTTP, and HTTPS.
  • Use a subdomain like doc.example.com instead of the root domain to avoid conflicts with other services.

Troubleshooting

OnlyOffice won’t start. Check logs with sudo docker compose logs. Common causes: insufficient memory, port conflicts, or a bad volume mount. Ensure no other service uses port 80/443.

Document editor shows “Connection lost�. This often happens when the JWT secret doesn’t match between OnlyOffice and the client (e.g., Nextcloud). Double-check both settings.

Can’t access the web interface. Verify the container is running (docker ps) and that the firewall allows traffic. Test with curl -I http://localhost from the server.

SSL certificate fails to renew. Certbot auto-renewal requires that your domain resolves to the server and port 80 is reachable. Test renewal manually with sudo certbot renew --dry-run.

OnlyOffice is slow. Check CPU and memory usage with htop. If the server is constantly swapping, increase RAM or reduce concurrent users.

Editing in Nextcloud fails with “Bad request�. Ensure the OnlyOffice URL in Nextcloud settings has no trailing slash, and the JWT secret is exactly the same.

Frequently Asked Questions

Can I use OnlyOffice without Docker?

Yes, but Docker is the officially supported method and simplifies upgrades. Manual installation is more complex and error-prone.

How many users can I host on a 4 GB VPS?

For light usage, 10-20 concurrent editors is realistic. Each active editor consumes about 200-300 MB of RAM. For larger teams, go with 8 GB or more.

Does OnlyOffice support real-time collaboration?

Yes, it supports co-editing with multiple users on the same document, with changes synced in real time.

Can I integrate OnlyOffice with other platforms like ownCloud or Seafile?

OnlyOffice has official connectors for Nextcloud, ownCloud, and others. For unsupported platforms, you can use the API directly.

Is it possible to use a free SSL certificate?

Yes, Let’s Encrypt provides free certificates, and the Certbot step above does exactly that. Just make sure your domain is valid.

What happens if my VPS runs out of disk space?

OnlyOffice may fail to save documents. Monitor disk usage with df -h and clean up old Docker images with docker image prune.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →