Artículos con :
Cerrar
Changelog
Cerrar
Pruébelo en la nube
Centro de ayuda
integración

Configuring reverse proxy for Nextcloud and ONLYOFFICE editors

Upon installing multiple server solutions on different machines, an issue with configuring a proxy server may appear.

In this particular 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.

To establish the correct connection, the following actions should be performed:

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

Read this article to find out how to properly configure a proxy server for nginx, Nextcloud and ONLYOFFICE Docs.

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.

The necessary 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 proxy_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

Again open 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.

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/.

Download Best editors on your website Let your site users view, edit and collaborate
on all types of text, spreadsheet and presentation files
También le podría gustar:
Cerrar