Install OnlyOffice on Ubuntu 22.04 and connect to Nextcloud

Nextcloud 24 and above comes with a default Office suite now which is based on Collabora CODE version and it works pretty well. But if you want to install OnlyOffice on a separate Ubuntu 22.04 server and then connect it to Nextcloud instead, read on how to do that.

What we will cover in this article:

  • OnlyOffice docker installation
  • Apache as reverse proxy
  • SSL via Certbot

Looking to upgrade to the latest OnlyOffice document server? Click here

What you need:

  • Ubuntu 22.04 server
  • Point a domain or sub domain to the server IP
  • Nextcloud already installed

Minimum requirements for OnlyOffice:

  • Single Core 2 GHz CPU
  • 2 GB of RAM or more
  • 20 GB of free space
  • 4 GB of swap

Initial setup

1st we will prepare our server and install some packages including docker etc.

apt install apt-transport-https ca-certificates curl software-properties-common

Add docker repository for Ubuntu 22.04:

curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg

add-apt-repository "deb [arch=amd64 signed-by=/usr/share/keyrings/docker.gpg] jammy stable"

Update the system and install Apache, docker.

apt update && apt install apache2 vim docker-ce

Enable Apache modules and enable it at boot time.

a2enmod ssl rewrite headers proxy proxy_http deflate cache proxy_wstunnel

systemctl enable apache2
systemctl start apache2

SSL and virtual host

Create a virtual host file oo.conf.

cd /etc/apache2/sites-available/
vim oo.conf

Paste the following in it and change DOMAIN.COM.

<VirtualHost *:80>

	ServerName DOMAIN.COM
    DocumentRoot /var/www/html

    <Directory "/var/www/html">
       AllowOverride All
       Options -Indexes +FollowSymLinks

	ErrorLog ${APACHE_LOG_DIR}/onlyoffice_error.log


Enable this configuration and disable the default one.

a2ensite oo.conf
a2dissite 000-default.conf

systemctl restart apache2

Install certbot via snap.

snap install certbot --classic

If snap is not installed:

apt install snapd

Get a staging certificate 1st to make sure your settings are correct.

Note: before running this command make sure your domain is pointed to the IP.

certbot certonly --test-cert --webroot -w /var/www/html -d DOMAIN.COM

If everything is good, get a production certificate.

certbot certonly --webroot -w /var/www/html -d DOMAIN.COM

OnlyOffice docker installation

Install OnlyOffice community document server via docker and start it in the background.

docker run -i -t -d -p --restart=always \
    -e JWT_ENABLED=true \
    -e JWT_SECRET=7bSds623nf2341k932ds2 \
    -e JWT_HEADER=Authorization \
    -e JWT_IN_BODY=true \
    -v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data onlyoffice/documentserver

Change JWT_SECRET to a strong secret.

You can check the docker containers with docker ps.

To enter a docker container:

docker exec -it CONTAINER_ID bash

Update virtual host

Till here if you have successfully installed everything, the last step is to update our virtual host file with SSL and reverse proxy to OnlyOffice container.

<VirtualHost *:443>

   ServerName DOMAIN.COM

   ErrorLog ${APACHE_LOG_DIR}/onlyoffice_error.log

   # SSL configuration
   SSLEngine on
   SSLCertificateFile /etc/letsencrypt/live/DOMAIN.COM/fullchain.pem
   SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN.COM/privkey.pem
   SSLProtocol all -SSLv2 -SSLv3
   SSLHonorCipherOrder on
   SSLCompression off

   SetEnvIf Host "^(.*)$" THE_HOST=$1
   RequestHeader setifempty X-Forwarded-Proto https
   RequestHeader setifempty X-Forwarded-Host %{THE_HOST}e
   ProxyAddHeaders Off

   ProxyPassMatch (.*)(\/websocket)$ "ws://$1$2"
   ProxyPass / ""
   ProxyPassReverse / ""


Restart Apache and go to the domain with https. You will see a welcome screen.

Connect to Nextcloud

Go to your Nextcloud instance and install OnlyOffice app from the store.

Now go to Settings as Admin and click ONLYOFFICE. Input the URL and secret, save.

After save you can change any settings and enable different options.



  1. I just wanted to say, “Thank you.”
    I tried the Nextcloud app install, but it had some (minor) errors and was not scalable.
    I tried other installations on the same server, but failed to get Apache/nginx to play nice.
    Your approach worked perfectly for my situation (both on the same server).
    Thanks again!

  2. Thanks for the instruction – working perfect.
    Can you make a tutorial how to update this OO instance?
    Would be great. 🙂

Comments are closed.