How to configure reverse proxy for Nextcloud and ONLYOFFICE editors

28 January 2020 By Ivan 2 20,397

Hi everyone!

Most of the ways to integrate ONLYOFFICE with Nextcloud are described in our API documentation, but some cases our users deal with in real life can be quite tricky. In this post, we’ll show you how to configure a proxy server for Nextcloud and ONLYOFFICE if all the three are installed on various servers.

In our case, there are three different machines with:

  • nginx – http://nginx,
  • Nextcloud – http://nextcloud,
  • ONLYOFFICE editors – http://onlyoffice.

Everything was installed using Docker and port 80.

We need to:

  • customize nginx so that a request on http://nginx would open Nextcloud,
  • customize Nextcloud to work with document editors available on http://nginx/editors/.

Let’s do it following this 3-step plan.

Step 1. Setting up a proxy for Nextcloud

To proxy Nextcloud via nginx, change nginx settings and add its address to Nextcloud trusted domains list. More on trusted domains can be found in the documentation.

The needed settings are located in the nginx container at /etc/nginx/conf.d/default.conf. Make this file look like:


Pay attention to the slash at the end of the prox_pass path.

Refresh the nginx settings with:

Now add http://nginx domain. Open the configuration in Nextcloud container at /var/www/html/config/config.php. Find or add trusted_domain section there and add nginx address. After all the changes are effective, this part of the configuration will look like:

Step 2. Setting up a proxy for document editors

Open again default.conf on the nginx server and add one more location:

But that won’t be enough for editors to run. By default, the document editor generates links to resources using the address that comes in a request. So far as the editor is not connected to the proxy server, it will generate links irrespective of the virtual path (e.g. http://nginx/apps/files/). This is not correct as the /apps/files/ are located on the http://onlyoffice/ server.

To fix this, in the request header, you need to indicate the path for generating the links with the ‘X-Forwarded-Host’ header.

Let’s add the following code at the beginning of the configuration file:

Two more important headers are Upgrade and Connection. They allow using websocket protocol to effectively run ONLYOFFICE.

The resulting default.conf file will look the following way:

Step 3. Installing ONLYOFFICE-Nextcloud connector

Use our ready connector to link ONLYOFFICE and Nextcloud instances to each other. The connector is available on GitHub, but the easiest way is to install it from Nextcloud app store.

After installation, you will see a new option in the settings menu. There, you’ll need to specify the address of ONLYOFFICE editors – http://nginx/editors/.

Useful links

Download the latest version of the ONLYOFFICE connector for Nextcloud from the Nextcloud App Store.

Get ONLYOFFICE online editors for your Nextcloud -> Fill in this form or Download the free version.

Install ONLYOFFICE-Nextcloud combo all at once using Docker Compose.

Find useful tips on ONLYOFFICE-Nextcloud integration in this beginner’s guide, or watch the replay of our webinar.

If you have any questions, tweet us at @only_office. Your feedback is much appreciated!

Comments (2)
  1. Alex - Reply
    September 23, 2021 at 12:18 pm


    According to the document , the part of the configuration config.php must looks like

    ‘trusted_domains’ => array (0 => ‘nextcloud’, 1 => ‘nginx’,),

  2. TravisP - Reply
    February 9, 2022 at 8:48 am

    This needs to be updated to show pepper setup in the onlyoffice app of nextcloud.

Add a comment