How to configure reverse proxy for Nextcloud and ONLYOFFICE editors

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:


server { 
        listen 80; 
        location / { 
            proxy_pass_header   Server; 
            proxy_pass          http://nextcloud/; 

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

Refresh the nginx settings with:

service nginx reload

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:

‘trusted_domain’ => (0 => ‘nextcloud’, 1 => ‘nginx’)
Step 2. Setting up a proxy for document editors

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

location /editors/ {     
    proxy_pass http://onlyoffice/; 

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 ‘X-Forwarded-Host’ header.

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

proxy_set_header X-Forwarded-Host $http_host/editors;

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:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $http_host/editors;
server {
        listen 80;
        location / {
            proxy_pass_header Server;
            proxy_pass http://nextcloud/;
        location /editors/ {
            proxy_pass http://onlyoffice/;
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!


Recent Posts

  • Android apps
  • Call for testing

Call for testing: Native ONLYOFFICE Documents 4.0 for Android

Hello everyone! Today we are offering a chance to contribute to our project by becoming a beta tester of the…

3 days ago
  • What's new

ONLYOFFICE releases official connector for Plone

Good news, everyone! From now on you can collaborate on docs within Plone using ONLYOFFICE online editors. Our free open-source…

4 days ago

ONLYOFFICE and Elasticsearch: better and faster navigation through documents, emails and other content

Hello everyone! Recently we have integrated Elasticsearch, a powerful open source search and analytics engine, into ONLYOFFICE solutions to make…

6 days ago

Integration Edition at home: 10 users for $99

We are launching a new tariff plan for those who need professional editing features at home. It is called Home…

1 week ago
  • Documents
  • Documents

ONLYOFFICE Documents 6.0 for iOS: Dark Mode, new formats and other improvements

Great news, Apple fans! ONLYOFFICE has updated its mobile office suite for iOS and added Dark Mode, improved stability and…

2 weeks ago
  • Special offer

Ease the transition into remote work with ONLYOFFICE 180-day free trial

Hello everyone! Lots of employers around the globe are now bound to encourage employees to work remotely in order to…

2 weeks ago

This website uses cookies. By continuing to browse the website you agree to our privacy policy.

our privacy policy