ONLYOFFICE Docs v7.3 released: enhanced forms, SmartArt, new security settings, Watch Window, and more
ONLYOFFICE Docs v7.3 released

"Download failed" when accessing OnlyOffice docker through Nginx proxy

I am trying to install OnlyOffice Community Edition for use with a self-hosted Nextcloud on the same server (Nginx). I have installed OnlyOffice using Docker following these instructions. The test instance is working properly, when accessed through the local ip address and correct port (in my case 192.168.1.1:8080). In order to access OnlyOffice from the internet, i configured Nginx as a proxy. For testing, i used the following (minimal) configuration file:

server {
  server_name mydomain.net office.mydomain.com;
  location / {
    proxy_pass http://localhost:8080;
  }
}

With this setup, i am able to access the welcome page of OnlyOffice through http://office.mydomain.com, but as soon as i try to open a document from the example, a warning (“The document could not be saved”) and an error (“Download failed”) appear.

The following output is written to the file docservice/out.log:

[2023-01-20T17:06:07.618] [ERROR] [localhost] [172.17.0.1new.xlsx1674234365807] [uid-1] nodeJS - postData error: url = http://localhost:8080/example/track?filename=new.xlsx&useraddress=172.17.0.1;data = {"key":"172.17.0.1new.xlsx1674234365807","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}],"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiIxNzIuMTcuMC4xbmV3Lnhsc3gxNjc0MjM0MzY1ODA3Iiwic3RhdHVzIjoxLCJ1c2VycyI6WyJ1aWQtMSJdLCJhY3Rpb25zIjpbeyJ0eXBlIjoxLCJ1c2VyaWQiOiJ1aWQtMSJ9XSwiaWF0IjoxNjc0MjM0MzY3LCJleHAiOjE2NzQyMzQ2Njd9.t7ukpZm8z045DAxZ1eGxJqq7omajCg-T0WHQNW5coBY"} Error: connect ECONNREFUSED 127.0.0.1:8080
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)
[2023-01-20T17:06:15.172] [ERROR] [localhost] [172.17.0.1new.xlsx1674234365807] [uid-1] nodeJS - postData error: url = http://localhost:8080/example/track?filename=new.xlsx&useraddress=172.17.0.1;data = {"key":"172.17.0.1new.xlsx1674234365807","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}],"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXkiOiIxNzIuMTcuMC4xbmV3Lnhsc3gxNjc0MjM0MzY1ODA3Iiwic3RhdHVzIjoxLCJ1c2VycyI6WyJ1aWQtMSJdLCJhY3Rpb25zIjpbeyJ0eXBlIjoxLCJ1c2VyaWQiOiJ1aWQtMSJ9XSwiaWF0IjoxNjc0MjM0Mzc1LCJleHAiOjE2NzQyMzQ2NzV9.kIM09Y-A1CZucq8qqrXb1nqlHS-rtor0RJFel7aRDSw"} Error: connect ECONNREFUSED 127.0.0.1:8080
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16)

According the troubleshooting page, this error occurs if “The Document editing service cannot upload the file for editing.” and i should “Check if the link to the file specified in the document.url is correct. The link must be accessible from the document editing service.”

How can i figure out the link and check, whether it is accessible?

Hello @eric_nc
I believe the described issue is related to your Nginx settings, because test instance works properly. Please take a look at this title: Using ONLYOFFICE Docs behind the proxy - ONLYOFFICE
It contains examples of config files to use a proxy in front of Document server.

Thank you! I got it working.

My exact setup didn’t seem to be covered by the example config files, since i am using OnlyOffice behind a subdomain (office.mydomain.com), with other services running on their own subdomains on the same server. So I used minimal.conf as basis and made the following changes:

#Use this example for proxy traffic to the document server running at 'backendserver-address'.

upstream docservice {
  server localhost:8080;    #### CHANGE ####
}

map $http_host $this_host {
    "" $host;
    default $http_host;
}

map $http_x_forwarded_proto $the_scheme {
     default $http_x_forwarded_proto;
     "" $scheme;
}

map $http_x_forwarded_host $the_host {
    default $http_x_forwarded_host;
    "" $this_host;
}

map $http_upgrade $proxy_connection {
  default upgrade;
  "" close;
}

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Proto $the_scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

server {
  server_name mydomain.com office.mydomain.com;          #### CHANGE ####
  listen 0.0.0.0:80;
  listen [::]:80 default_server;
  server_tokens off;

  location / {
    proxy_pass http://docservice;
    proxy_http_version 1.1;
  }
}

I am not sure, whether my modifications are orthodox, but at least nginx did not complain (tested with “nginx -t”).

After successfully testing the unencrypted setup, i used Certbot to integrate SSL encryption. It added a few changes to the above config file. Now everything seems to work fine with SSL as well :slight_smile:

We are glad that the issue is solved. Please feel free to contact us if you face any issues.