How to Integrate OnlyOffice with NextCloud

ownCloud users can use OnlyOffice online editors to edit office documents right from their ownCloud installation, thanks to the ownCloud OnlyOffice integration app released in February 2017. Now OnlyOffice has updated its integration app to add support for Nextcloud. This tutorial will be showing you how to integrate OnlyOffice with Nextcloud using the Nextcloud OnlyOffice integration app.

The Nextcloud OnlyOffice integration app features:

  • Full-featured text editor available online with all the functionality of desktop editors.
  • 100% view, conversion, print and pagination fidelity.
  • Add links, tables and charts, insert images, auto shapes, formulas and text objects and manipulate them, create bulleted or numbered lists and more.
  • Real-time collaborative editing with your teammates: show changes instantly or after saving only. Use commenting and built-in chat, reviewing and tracking changes.
  • Support for most popular formats: edit DOCX, XLSX, PPTX, TXT files and save in ODT, ODS, ODP, DOC, XLS, PPT, PPS, EPUB, RTF, HTML, HTM.

To complete this guide, you will need to

  • Have a working Nextcloud server. See the Nextcloud installation on Ubuntu tutorial if you haven’t installed it.
  • Install OnlyOffice document server running in HTTPS
  • Install Nextcloud OnlyOffice integration app on Nextcloud server

The OnlyOffice document server and Nextcloud server can be installed on two different hosts Let’s get started.

Installing ONLYOFFICE Document Server

Please note that OnlyOffice document server requires at least 2GB of RAM. An additional 2GB of swap space is recommended. OnlyOffice document server depends on PostgreSQL, Node.js, Redis Server, RabbitMQ server and Nginx. The following steps are tested on a Ubuntu 16.04 server but should also be applicable to other Debian-based Linux distributions.

Install PostgreSQL from Ubuntu repository

sudo apt install postgresql

Then create the onlyoffice database.

sudo -u postgres psql -c "CREATE DATABASE onlyoffice;"

Create the onlyoffice user.

sudo -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"

Grant permission.

sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

Install NodeJS from official repository

OnlyOffice document server requires nodejs 8.0+, but the version in Ubuntu repository is outdated, so we will need to install the latest LTS version (8.12.0) of Node.js from upstream repository.

Add Node.js repostiory.

curl -sL | sudo -E bash -

Install Node.js.

sudo apt install nodejs

Check Node.js version.

node -v

Sample output:


Install Redis server and Rabbitmq

sudo apt install redis-server rabbitmq-server

Check their status.

systemctl status redis-server

systemctl status rabbitmq-server

You should see they are active (running).  If rabbitmq-server failed to start, that’s mostly because of low memory on the machine or invalid hostname.

Install OnlyOffice document server

Add OnlyOffice repository with the following command.

echo "deb squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list

Import OnlyOffice public key.

sudo apt-key adv --keyserver hkp:// --recv-keys CB2DE8E5

Update local package index and install OnlyOffice document server. Note that Nginx will be installed as the web server so you might need to stop Apache if it’s running.

sudo apt update

sudo apt install onlyoffice-documentserver

During the installation process, you will be asked to enter PostgreSQL password for onlyoffice. Enter “onlyoffice” (without double quotes).

onlyoffice document server install

You also need to accept the Microsoft license terms in order to install TrueType core fonts from Microsoft.

install onlyoffice document server on ubuntu 16.04

Once the installation is finished, enter your server’s public IP address in web browser, you should see “Document Server is running”

onlyoffice document server

Enabling HTTPS

To connect NextCloud to OnlyOffice document server, the latter must be running in HTTPS mode. The following steps show how to obtain and install Let’s Encrypt TLS certificate.

Edit /etc/nginx/conf.d/onlyoffice-documentserver.conf file.

sudo nano /etc/nginx/conf.d/onlyoffice-documentserver.conf

Change the configuration like below. Don’t forget to set an A record for

include /etc/nginx/includes/onlyoffice-http.conf;
server {
  listen [::]:80 default_server;
  server_tokens off;

  include /etc/nginx/includes/onlyoffice-documentserver-*.conf;

  location ~ /.well-known/acme-challenge {
        root /var/www/onlyoffice/;
        allow all;

Save and close the file. Reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Then install certbot (Let’s Encrypt) client.

sudo apt install letsencrypt

Next, run the following command to obtain a free TLS certificate using the webroot plugin.

sudo letsencrypt certonly --webroot --agree-tos --email your-email-address -d -w /var/www/onlyoffice/

Within a few seconds, you shall see a message like below, which means the TLS certificate is successfully obtained.

onlyoffice https

Edit onlyoffice-documentserver.conf file.

sudo nano /etc/nginx/conf.d/onlyoffice-documentserver.conf

Delete everything in that file and paste the following text into the file. Change the red text accordingly.

include /etc/nginx/includes/onlyoffice-http.conf;
## Normal HTTP host
server {
  listen [::]:80 default_server;
  server_tokens off;
  ## Redirects all traffic to the HTTPS host
  root /nowhere; ## root doesn't have to be a valid path since we are redirecting
  rewrite ^ https://$host$request_uri? permanent;
#HTTP host for internal services
server {
  listen [::1]:80;
  server_name localhost;
  server_tokens off;
  include /etc/nginx/includes/onlyoffice-documentserver-common.conf;
  include /etc/nginx/includes/onlyoffice-documentserver-docservice.conf;
## HTTPS host
server {
  listen ssl;
  listen [::]:443 ssl default_server;
  server_tokens off;
  root /usr/share/nginx/html;
  ssl_certificate /etc/letsencrypt/live/;
  ssl_certificate_key /etc/letsencrypt/live/;

  # modern configuration. tweak to your needs.
  ssl_protocols TLSv1.2;
  ssl_prefer_server_ciphers on;

  # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
  add_header Strict-Transport-Security max-age=15768000;

  ssl_session_cache builtin:1000 shared:SSL:10m;
  # add_header X-Frame-Options SAMEORIGIN;
  add_header X-Content-Type-Options nosniff;
  # ssl_stapling on;
  # ssl_stapling_verify on;
  # ssl_trusted_certificate /etc/nginx/ssl/stapling.trusted.crt;
  # resolver valid=300s; # Can change to your DNS resolver if desired
  # resolver_timeout 10s;
  ## [Optional] Generate a stronger DHE parameter:
  ##   cd /etc/ssl/certs
  ##   sudo openssl dhparam -out dhparam.pem 4096
  #ssl_dhparam {{SSL_DHPARAM_PATH}};

  location ~ /.well-known/acme-challenge {
     root /var/www/onlyoffice/;
     allow all;
  include /etc/nginx/includes/onlyoffice-documentserver-*.conf;

Save and close the file. Then test Nginx configuration and reload.

sudo nginx -t

sudo systemctl reload nginx

Visit in web browser to verify OnlyOffice document server is running correctly in HTTPS mode.

onlyoffice nextcloud

Installing Nextcloud OnlyOffice Integration App

SSH into your Nextloud server, and then change directory to the Nextcloud apps directory.

cd /var/www/nextcloud/apps/

Next, download Nextcloud OnlyOffice integration app using the following command.

sudo git clone onlyoffice

Then go to Nextcloud Apps page, click Not Enabled tab and enable the OnlyOffice app.

nextcloud onlyoffice integration app


After that, go to Nextcloud admin page, select Additional Settings tab on the left pane and enter the domain name for OnlyOffice in Document Editing Service Address field.

nextcloud onlyoffice app

After saving the above setting, you should be able to create documents, spreedsheets and presentation files within Nextcloud by clicking the plus (+) button. A separate tab will be opened for editing.

nextcloud onlyoffice

You will also see a new item called “Open in OnlyOffice” in the context menu of office documents.

Installing OnlyOffice Document Server and Nextcloud on the Same Host

The OnlyOffice Document server uses Nginx as web server.

If you have an existing Nextcloud server running with Nginx, then there’s no damage to your Nextcloud server when installing OnlyOffice on the same machine. It will remove nginx-core and install nginx-extras package, so there’ll be a little downtime, but your configurations will be intact.

If you have an existing Nextcloud server running with Apache web server, and you want to install OnlyOffice on the same machine, then you have two choices:

Configuring Nginx as a Reverse Proxy for Apache

If you choose the second route, then you should first change the port number of Apache before you install OnlyOffice document server.

Edit the ports.conf file.

sudo nano /etc/apache2/ports.conf

Find the line:

Listen 80

Change it to a different port number like 8180. Note that you shouldn’t use 8080 here because OnlyOffice document server needs port 8080 to start its docservice.

Listen 8180

You should also change the SSL port number because later Nginx will do the SSL termination. Find the line:

Listen 443

Change the port number to something like 4433.

Listen 4433

Save and close the file. Next, edit the virtual host file for Nextcloud.

sudo nano /etc/apache2/sites-enabled/nextcloud.conf

The first line should be like this:

<VirtualHost *:80>

Change the port number to 8180.

<VirtualHost *:8180>

We should also disable redirecting HTTP to HTTPS by adding comment characters before the following lines. (Your Nextcloud server is using HTTPS connection, right?)

#RewriteEngine on
#RewriteCond %{SERVER_NAME}
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]

And change the SSL listening port.

<VirtualHost *:443>

Change the above port to 4433. Save and close the file. Reload Apache configuration.

sudo systemctl reload apache2

Now Apache listens on port 8180 and 4433. We can then follow the above instructions to install OnlyOffice document server, which will install Nginx in the process.

Once OnlyOffice document server and Nginx are installed, create an Nginx server block file to proxy requests to Apache.

sudo nano /etc/nginx/conf.d/nextcloud-proxy.conf

Add the following lines to the file. Replace the domain name with your own. The path for ssl_certificate and ssl_certificate_key is for Let’s Encrypt issued certificates. If you use a certificate issued by another CA, then you should enter your own path.

server {
        listen 80;
        return 301 https://$server_name$request_uri;

server {
        listen 443 ssl http2;

        ssl_certificate /etc/letsencrypt/live/;
        ssl_certificate_key /etc/letsencrypt/live/;

        ssl_session_timeout 1d;
        ssl_session_cache shared:SSL:10m;
        ssl_session_tickets off;
        ssl_protocols TLSv1.1 TLSv1.2;

        add_header Strict-Transport-Security max-age=15768000;

        ssl_prefer_server_ciphers on;

        location / {
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

The location / {...} section redirects all requests to Apache web server listening on port 8180. Save and close the file. Then test Nginx configuration.

sudo nginx -t

Reload Nginx if syntax is OK.

sudo systemctl reload nginx

Now you should be able to visit your Nextcloud server as usual, without adding a port number in the URL. If you use the following cURL command to fetch HTTP header, then you should see the front-end server is Nginx.

curl -I

Sample output:

HTTP/1.1 302 Found
Server: nginx/1.11.9
Date: Tue, 14 Mar 2017 08:55:30 GMT
Content-Type: text/html; charset=UTF-8

That’s it!

I hope this tutorial helped you with integrating OnlyOffice with Nextcloud. As always, if you found this post useful, then subscribe to our free newsletter. You can also follow us on Google+Twitter or like our Facebook page.

Rate this tutorial
[Total: 21 Average: 3.6]

report this ad

19 Responses to “How to Integrate OnlyOffice with NextCloud

  • Berndhard Schmitz
    12 months ago

    I got this error while installing onlyoffice-documentserver:

    All done, no errors.
    All fonts downloaded and installed.
    Traceback (most recent call last):
    File “/usr/lib/update-notifier/package-data-downloader”, line 278, in process_download_requests
    FileNotFoundError: [Errno 2] No such file or directory: ‘/var/lib/update-notifier/package-data-downloads/partial/arial32.exe’
    Setting up ttf-mscorefonts-installer (3.4ubuntu3) …
    Setting up gconf-service-backend (3.2.6-3ubuntu6) …
    Processing triggers for libc-bin (2.23-0ubuntu9) …
    Processing triggers for systemd (229-4ubuntu20) …
    Errors were encountered while processing:
    E: Sub-process /usr/bin/dpkg returned an error code (1)

    How can I fix it?
    Thank you.

    • you should enable contrib and non-free comps for the debian repositories in /etc/apt/sources.list

  • Hi,

    Does somebody have an idea how to change the GUI language? In the “normal” installation of OnlyOffice there is a settings page at https://onlyoffice.domain.tld but with this integrated server there isn’t – or I can’t find it.
    What can I do to change the GUI to German language?

    Thanks and best regards

  • Jan Heiniger
    12 months ago

    Is it somehow possible to Install this with Apache?
    Nginx wont start the service because its missing the “/etc/nginx/includes/onlyoffice-http.conf” file and i dont like having 2 web-services.
    Add fyi: I already tried Collabora Online, also didnt work for me

  • Hello !! Thank’s a lot for this tutorial ! Very well written, I never feel lost, perfect !
    Unfortunately, I have a problem, just at the end..

    When I try to configure OnlyOffice in my Nextcloud.
    I set the adress and I have this error : Error when trying to connect (Bad Request or timeout error)

    I read some posts on the Internet and I see that when I launch a wget from my NC server to my OO server, I have this error :

    Resolving (… ip adress
    Connecting to (|ip adress|:443… connected.
    ERROR: The certificate of ‘’ is not trusted.
    ERROR: The certificate of ‘’ hasn’t got a known issuer.

    I have to do something to make my NC server trust in my OO server ?

    Thank a lot in advance for your help 🙂

  • For future readers: the Onlyoffice install appears to require the npm package as well (at least I couldn’t get it to work until I installed npm), and some Ubuntu installations may not have it. Without npm the document server install failed for me, and it wasn’t at all obvious why.

    To fix this, just issue the command:

    sudo apt install npm

    before the “Install OnlyOffice document server” step.

    Other than this one thing, these instructions worked for me precisely.

  • (Note: this was Nextcloud v14.0.1 on Ubuntu 18.04.1.)

    One further note: the Ubuntu repository has been updated with a current version of NodeJS, so this step:

    curl -sL | sudo -E bash –

    is no longer necessary (at least with 18.04; not sure about older Ubuntu versions).

  • heliop100
    8 months ago

    I’m receiving bad request or timeout when saving the onlyoffice integration.
    I’m using wildcard certificate for both nextcloud and onlyoffice.

  • $ sudo apt-key adv --keyserver hkp:// --recv-keys CB2DE8E5

    affter that line I get below error

    Executing: /tmp/apt-key-gpghome.pkK8eBiyYd/ --keyserver hkp:// --recv-keys CB2DE8E5
    gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
    gpg: connecting dirmngr at '/tmp/apt-key-gpghome.pkK8eBiyYd/S.dirmngr' failed: No such file or directory
    gpg: keyserver receive failed: No dirmngr

    I am debian 9.5
    how to fix the error

  • thank you Xiao
    by installing dirmngr the key imported successfully
    but another problem as bellow :

    $ sudo apt install onlyoffice-documentserver
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    The following packages have unmet dependencies:
     onlyoffice-documentserver : Depends: nodejs (>= 8.0.0) but 6.14.4-1nodesource1 is to be installed
    E: Unable to correct problems, you have held broken packages.

    thanks for helps

    • OnlyOffice document server now requires nodejs 8.0+. Run the following commands to install it.

      curl -sL | sudo -E bash -
      sudo apt install nodejs
  • thanks Xiao for above helps
    but I need more help
    please tack look thise errors:

    :/$ sudo apt install onlyoffice-documentserver
    Setting up nginx-extras (1.10.3-1+deb9u1) ...
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.
    invoke-rc.d: initscript nginx, action "start" failed.
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Wed 2018-10-10 17:07:37 CEST; 9ms ago
         Docs: man:nginx(8)
      Process: 28831 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)
      Process: 28826 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Oct 10 17:07:36 tbnext nginx[28831]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
    Oct 10 17:07:36 tbnext nginx[28831]: nginx: [emerg] listen() to, backlog 511 failed (98: Address already in use)
    Oct 10 17:07:36 tbnext nginx[28831]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
    Oct 10 17:07:37 tbnext nginx[28831]: nginx: [emerg] listen() to, backlog 511 failed (98: Address already in use)
    Oct 10 17:07:37 tbnext nginx[28831]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98: Address already in use)
    Oct 10 17:07:37 tbnext nginx[28831]: nginx: [emerg] still could not bind()
    Oct 10 17:07:37 tbnext systemd[1]: nginx.service: Control process exited, code=exited status=1
    Oct 10 17:07:37 tbnext systemd[1]: Failed to start A high performance web server and a reverse proxy server.
    Oct 10 17:07:37 tbnext systemd[1]: nginx.service: Unit entered failed state.
    Oct 10 17:07:37 tbnext systemd[1]: nginx.service: Failed with result 'exit-code'.
    dpkg: error processing package nginx-extras (--configure):
     subprocess installed post-installation script returned error exit status 1
    Setting up libboost-regex1.62-dev:amd64 (1.62.0+dfsg-4) ...
    dpkg: dependency problems prevent configuration of onlyoffice-documentserver:
     onlyoffice-documentserver depends on nginx-extras (>= 1.3.13); however:
      Package nginx-extras is not configured yet.
    dpkg: error processing package onlyoffice-documentserver (--configure):
     dependency problems - leaving unconfigured
    Setting up libboost-regex-dev:amd64 ( ...
    Processing triggers for libc-bin (2.24-11+deb9u3) ...
    Errors were encountered while processing:
    W: Automatically disabled Acquire::http::Pipeline-Depth due to incorrect response from server/proxy. (man 5 apt.conf)
    E: Sub-process /usr/bin/dpkg returned an error code (1)


    • There’s another process using port 80 on your server (Maybe Apache?) You need to stop it or configure it to use another port so that Nginx can bind to port 80. Then reinstall onlyoffice-documentserver.

  • Sometimes (and too many times), I get the “the file cannot be access right now” error. If I refresh the page, it comes back. I may or may-not lose my most recent editions (it varies). Many times it works without errors, then they surface again for no apparent reason. Are there time-out configuration settings for Office only? or anything else that causes this error

  • Hello. I’m running Nextcloud 14 version on Ubuntu 16.04. TLS
    Following above instructions i have installed onlyoffice document server on another machine Ubuntu 16.04. TLS
    All installation passed successful.
    Now when i try to create a new document on nextcloud, I got blank page with only text “Loading, please wait” and in address bar of browser i see “about:blank” Looks like it is not redirecting.
    However i’m able to edit existed documents. It works perfect.
    I’m a new in Linux environment, some help with details will be very appreciated.
    Thanks in advance for the help !

  • Hi Xiao Guo-An
    finally I installed onlyoffice documentserver
    but it is not support RTL for right to left languages as Arabic.
    can you please guide me how to solve this problem?


  • Mark Ellis
    2 weeks ago

    I currently have a Nextcloud Hosting instance through Hetzner Online (a German company); being a Microsoft Office 365 user, my comfort level is highest with that which has the greatest compatibility with the MS O365 formats, which – in my estimation – is OnlyOffice. It’s my understanding from Hetzner Online that all they do is host Nextcloud for me. I have to configure the OnlyOffice component of the Nextcloud hosting instance to connect to the OnlyOffice Document Server.

    I have a Raspberry Pi 3 B+, as well as a 13-year-old Dell Dimension E521 (1.8GHz AMD Sempron 3400+ processor & 4GB RAM); I sometimes use the Dell at home for various tasks; however, the Pi is currently unused.

    Between the Dell and the Pi, what would be the best place for the installation of the OnlyOffice Document Server?

    As a follow-up question, since my ISP (COX Communications) assigns residential customers a dynamic IP address, I assume that I could use a Dynamic DNS Service (DDNS) such as (which is supported by the COX router I have in my house) to make the eventual OnlyOffice Document Server accessible outside of my house, right? IF SO, would it be better to put the Server on the Pi since it’s not used currently? I do have some – not much – personal/family things on the Dell that I wouldn’t want to place at risk by it being open to the Internet, but I’m afraid that the little (but good) Pi might be overwhelmed with the OnlyOffice Document Server.

    I envision the main documents being worked on would be those compatible with MS Word and MS Excel. Formatting would be consistent with that used by homes or small businesses, so nothing advanced – like macros, links to separate files, database connections, etc.

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • If my answer helped you, please consider supporting this site. Thanks :)