[GH-ISSUE #403] Reverse proxy Nginx not working as expected #206

Closed
opened 2026-02-26 10:30:58 +03:00 by kerem · 6 comments
Owner

Originally created by @zadrarion on GitHub (Feb 2, 2022).
Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/403

Originally assigned to: @igwyd on GitHub.

Do you want to request a feature or report a bug?
Bug

I've setup a really simple docker documentserver in standard http with a nginx reverse proxy for https deliver by let's encrypt.
I turning on the example for try purpose and i always get :
image
image

i've try many option :

  • setup https only with the documentserver container -> work but i really need reverse proxy
  • setup only a reverse proxy with https -> not work
  • http only -> work as expected
  • use nginx proxy manager -> same problem, not work only for read document with same error

the log from the documentserver container:

[2022-02-02T20:43:16.087] [ERROR] nodeJS - error downloadFile:url=https://onlyoffice.xxx.xx/download?fileName=new.docx&useraddress=xx.xx.xx.xx__172.16.8.247;attempt=3;code:null;connect:null;(id=xx.xx.xx.xx__172.16.8.247https___onlyoffice.z-medley.fr_files_xx.xx.xx.xx__172.16.8.247_new.docx1643813341423)
Error: Error response: statusCode:404; headers:{"server":"nginx","date":"Wed, 02 Feb 2022 20:43:16 GMT","content-type":"text/html","transfer-encoding":"chunked","connection":"keep-alive","content-encoding":"gzip"};
    at Request.fResponse (/snapshot/server/build/server/Common/sources/utils.js)
    at Request.emit (events.js:400:28)
    at Request.onRequestResponse (/snapshot/server/build/server/Common/node_modules/request/request.js:1059:10)
    at ClientRequest.emit (events.js:400:28)
    at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
    at TLSSocket.socketOnData (_http_client.js:515:22)
    at TLSSocket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:290:12)
    at readableAddChunk (internal/streams/readable.js:265:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:204:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)

My nginx configuration for onlyoffice

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;
}

gzip off;

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;
proxy_set_header X-Real-IP $remote_addr;

server {
    listen 0.0.0.0:443 ssl;
    listen [::]:443 ssl;
    server_name onlyoffice.xxxxx.xx
    server_tokens off;
    root /usr/share/nginx/html;

    ssl_certificate /etc/nginx/certs/onlyoffice.crt;
    ssl_certificate_key /etc/nginx/certs/onlyoffice.key;
    ssl_verify_client off;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_prefer_server_ciphers   on;

    add_header X-Content-Type-Options nosniff;
    
    location / {
      proxy_pass http://172.16.8.250:80/;
      proxy_buffers 4 256k; 
      proxy_max_temp_file_size 0;
      proxy_http_version 1.1;
  }
}

i don't know if the problem happened on previous version of the container.
Docker is setup on this VM
image

i don't know what i doing wrong, i have setup all the content with this pages:
https://helpcenter.onlyoffice.com/en/installation/docs-community-install-docker.aspx
https://helpcenter.onlyoffice.com/en/installation/docs-community-proxy.aspx

Originally created by @zadrarion on GitHub (Feb 2, 2022). Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/403 Originally assigned to: @igwyd on GitHub. **Do you want to request a *feature* or report a *bug*?** Bug I've setup a really simple docker documentserver in standard http with a nginx reverse proxy for https deliver by let's encrypt. I turning on the example for try purpose and i always get : ![image](https://user-images.githubusercontent.com/13852927/152234147-207946b6-d1ea-4a1d-9002-f1647b8e1ce8.png) ![image](https://user-images.githubusercontent.com/13852927/152234232-b67b8477-6150-4e4f-ae86-c86dfb734e9d.png) i've try many option : - setup https only with the documentserver container -> work but i really need reverse proxy - setup only a reverse proxy with https -> not work - http only -> work as expected - use nginx proxy manager -> same problem, not work only for read document with same error the log from the documentserver container: ``` [2022-02-02T20:43:16.087] [ERROR] nodeJS - error downloadFile:url=https://onlyoffice.xxx.xx/download?fileName=new.docx&useraddress=xx.xx.xx.xx__172.16.8.247;attempt=3;code:null;connect:null;(id=xx.xx.xx.xx__172.16.8.247https___onlyoffice.z-medley.fr_files_xx.xx.xx.xx__172.16.8.247_new.docx1643813341423) Error: Error response: statusCode:404; headers:{"server":"nginx","date":"Wed, 02 Feb 2022 20:43:16 GMT","content-type":"text/html","transfer-encoding":"chunked","connection":"keep-alive","content-encoding":"gzip"}; at Request.fResponse (/snapshot/server/build/server/Common/sources/utils.js) at Request.emit (events.js:400:28) at Request.onRequestResponse (/snapshot/server/build/server/Common/node_modules/request/request.js:1059:10) at ClientRequest.emit (events.js:400:28) at HTTPParser.parserOnIncomingClient (_http_client.js:647:27) at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17) at TLSSocket.socketOnData (_http_client.js:515:22) at TLSSocket.emit (events.js:400:28) at addChunk (internal/streams/readable.js:290:12) at readableAddChunk (internal/streams/readable.js:265:9) at TLSSocket.Readable.push (internal/streams/readable.js:204:10) at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) ``` My nginx configuration for onlyoffice ``` 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; } gzip off; 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; proxy_set_header X-Real-IP $remote_addr; server { listen 0.0.0.0:443 ssl; listen [::]:443 ssl; server_name onlyoffice.xxxxx.xx server_tokens off; root /usr/share/nginx/html; ssl_certificate /etc/nginx/certs/onlyoffice.crt; ssl_certificate_key /etc/nginx/certs/onlyoffice.key; ssl_verify_client off; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_session_cache builtin:1000 shared:SSL:10m; ssl_prefer_server_ciphers on; add_header X-Content-Type-Options nosniff; location / { proxy_pass http://172.16.8.250:80/; proxy_buffers 4 256k; proxy_max_temp_file_size 0; proxy_http_version 1.1; } } ``` i don't know if the problem happened on previous version of the container. Docker is setup on this VM ![image](https://user-images.githubusercontent.com/13852927/152235151-a1afa780-0646-4e4c-bf32-3128757e86c6.png) i don't know what i doing wrong, i have setup all the content with this pages: https://helpcenter.onlyoffice.com/en/installation/docs-community-install-docker.aspx https://helpcenter.onlyoffice.com/en/installation/docs-community-proxy.aspx
kerem 2026-02-26 10:30:58 +03:00
Author
Owner

@igwyd commented on GitHub (Feb 3, 2022):

Hello @zadrarion, nginx and onlyoffice-documentserver installed on the same vitrual machine?

<!-- gh-comment-id:1029050654 --> @igwyd commented on GitHub (Feb 3, 2022): Hello @zadrarion, nginx and onlyoffice-documentserver installed on the same vitrual machine?
Author
Owner

@zadrarion commented on GitHub (Feb 3, 2022):

Hello @igwyd, no they are on two distinct virtual machine

<!-- gh-comment-id:1029323269 --> @zadrarion commented on GitHub (Feb 3, 2022): Hello @igwyd, no they are on two distinct virtual machine
Author
Owner

@igwyd commented on GitHub (Feb 7, 2022):

Documentserver work with nginx reverse proxy, you can check it when connecting to integrators (all connectors). Dont work only included test example in documentserver-7.0.0.132 with reverse proxy. We fix it in next release (probably 7.0.1).

<!-- gh-comment-id:1031499566 --> @igwyd commented on GitHub (Feb 7, 2022): Documentserver work with nginx reverse proxy, you can check it when connecting to integrators ([all connectors](https://www.onlyoffice.com/en/all-connectors.aspx)). Dont work only included test example in documentserver-7.0.0.132 with reverse proxy. We fix it in next release (probably 7.0.1).
Author
Owner

@ant0nwax commented on GitHub (Feb 28, 2022):

Hi @ShockwaveNN i came until this bug here

and I see that the bug i reported (https://github.com/ONLYOFFICE/DocumentServer/issues/1659)
is more or less valid becasue i still cannot work with xls or ods, they open in the viewer in Nextcloud and not in the editor on desktop browser

so for this bug I am curious when will 7.1 be released

i am now only testing with the example and honestly NEXTcloud works better than the example :)

My setup for https://onlyoffice.comain.tld/example :

browser -> apache (httpd) https -> nginx https -> document-server

apache conf like here:
https://github.com/ONLYOFFICE/document-server-proxy/blob/master/apache/proxy-https-to-https.conf
(changed only backendserver-address to IP address and setifempty to set because my apache does not support setifempty)

nginx conf like here:
/etc/onlyoffice/documentserver/nginx/ds-ssl.conf.tmpl > ds.conf
(changed only certificates)

steps:

precondition: /etc/onlyoffice/documentserver/default.json

                                "agentOptions": {
                                        "ca": "/etc/pki/nginx/chain.pem"
                                },
                                "headers": {
                                        "User-Agent": "Node.js/6.13",
                                        "Connection": "Keep-Alive"
                                },
                                "gzip": true,
                                "rejectUnauthorized": false
  1. supervisorctl restart all && service nginx restart
  2. fresh incognito chrome browser
  3. navigate to https://onlyoffice.DELETED/example/
  4. Upload file: test.xlsx (1,2,3 will pass
  5. Press EDIT

Expected, editing possible
Real result: same error messages

  • 1st Download failed
  • 2nd The document could not be saved... (like on the screenshots)

result: /var/log/onlyoffice/documentserver/docservice/out.log

[2022-02-28T18:44:19.585] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins, you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability
[2022-02-28T18:44:19.714] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 7.0.0. Build: 132
[2022-02-28T18:44:43.591] [ERROR] nodeJS - postData error: docId = 192.168.1.14https___onlyoffice.DELETED_files_192.168.1.14_test.xlsx1646070276157;url = https://onlyoffice.DELETED/track?filename=test.xlsx&useraddress=192.168.1.14;data = {"key":"192.168.1.14https___onlyoffice.DELETED_files_192.168.1.14_test.xlsx1646070276157","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}]}
Error: Error response: statusCode:404; headers:{"server":"nginx","date":"Mon, 28 Feb 2022 17:44:43 GMT","content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","connection":"keep-alive","vary":"Accept-Encoding","x-powered-by":"Express","content-security-policy":"default-src 'none'","x-content-type-options":"nosniff","content-encoding":"gzip"}; body:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Cannot POST /track</pre>
</body>
</html>

    at Request._callback (/snapshot/server/build/server/Common/sources/utils.js)
    at Request.callback (/snapshot/server/build/server/Common/node_modules/request/request.js:185:22)
    at Request.emit (events.js:400:28)
    at Request.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:400:28)
    at Gunzip.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:519:28)
    at Gunzip.emit (events.js:400:28)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
<!-- gh-comment-id:1054507931 --> @ant0nwax commented on GitHub (Feb 28, 2022): Hi @ShockwaveNN i came until this bug here and I see that the bug i reported (https://github.com/ONLYOFFICE/DocumentServer/issues/1659) is more or less valid becasue i still cannot work with xls or ods, they open in the viewer in Nextcloud and not in the editor on desktop browser so for this bug I am curious when will 7.1 be released i am now only testing with the example and honestly NEXTcloud works better than the example :) My setup for https://onlyoffice.comain.tld/example : browser -> apache (httpd) https -> nginx https -> document-server apache conf like here: https://github.com/ONLYOFFICE/document-server-proxy/blob/master/apache/proxy-https-to-https.conf (changed only backendserver-address to IP address and setifempty to set because my apache does not support setifempty) nginx conf like here: /etc/onlyoffice/documentserver/nginx/ds-ssl.conf.tmpl > ds.conf (changed only certificates) steps: precondition: /etc/onlyoffice/documentserver/default.json ``` "requestDefaults": { "agentOptions": { "ca": "/etc/pki/nginx/chain.pem" }, "headers": { "User-Agent": "Node.js/6.13", "Connection": "Keep-Alive" }, "gzip": true, "rejectUnauthorized": false ``` 1. supervisorctl restart all && service nginx restart 2. fresh incognito chrome browser 3. navigate to https://onlyoffice.DELETED/example/ 4. Upload file: test.xlsx (1,2,3 will pass 5. Press EDIT Expected, editing possible Real result: same error messages - 1st Download failed - 2nd The document could not be saved... (like on the screenshots) result: /var/log/onlyoffice/documentserver/docservice/out.log ```[2022-02-28T18:44:19.583] [WARN] nodeJS - Express server starting... [2022-02-28T18:44:19.585] [WARN] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins, you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability [2022-02-28T18:44:19.714] [WARN] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 7.0.0. Build: 132 [2022-02-28T18:44:43.591] [ERROR] nodeJS - postData error: docId = 192.168.1.14https___onlyoffice.DELETED_files_192.168.1.14_test.xlsx1646070276157;url = https://onlyoffice.DELETED/track?filename=test.xlsx&useraddress=192.168.1.14;data = {"key":"192.168.1.14https___onlyoffice.DELETED_files_192.168.1.14_test.xlsx1646070276157","status":1,"users":["uid-1"],"actions":[{"type":1,"userid":"uid-1"}]} Error: Error response: statusCode:404; headers:{"server":"nginx","date":"Mon, 28 Feb 2022 17:44:43 GMT","content-type":"text/html; charset=utf-8","transfer-encoding":"chunked","connection":"keep-alive","vary":"Accept-Encoding","x-powered-by":"Express","content-security-policy":"default-src 'none'","x-content-type-options":"nosniff","content-encoding":"gzip"}; body: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot POST /track</pre> </body> </html> at Request._callback (/snapshot/server/build/server/Common/sources/utils.js) at Request.callback (/snapshot/server/build/server/Common/node_modules/request/request.js:185:22) at Request.emit (events.js:400:28) at Request.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1154:10) at Request.emit (events.js:400:28) at Gunzip.<anonymous> (/snapshot/server/build/server/Common/node_modules/request/request.js:1076:12) at Object.onceWrapper (events.js:519:28) at Gunzip.emit (events.js:400:28) at endReadableNT (internal/streams/readable.js:1317:12) at processTicksAndRejections (internal/process/task_queues.js:82:21) ```
Author
Owner

@igwyd commented on GitHub (Mar 2, 2022):

@zadrarion i checked, test example in onlyoffoce-documentserver-7.0.1 is work now with nginx reverse proxy, thank you for report.

@ant0nwax i think you should work with that in your issue report. There isn't apache config in this issue.

<!-- gh-comment-id:1056428196 --> @igwyd commented on GitHub (Mar 2, 2022): @zadrarion i checked, test example in onlyoffoce-documentserver-7.0.1 is work now with nginx reverse proxy, thank you for report. @ant0nwax i think you should work with that in your issue report. There isn't apache config in this issue.
Author
Owner

@ghost commented on GitHub (Mar 2, 2022):

I confirm on behalf of ant0nwax, that the issue that appeared on nginx side by using https inside of onlyoffice machine (not on the reverse proxy) and the reverse proxy is httpd (apache) with https, the issue is also solved, ant0nwax will continue on the other issue report...

<!-- gh-comment-id:1056499914 --> @ghost commented on GitHub (Mar 2, 2022): I confirm on behalf of ant0nwax, that the issue that appeared on nginx side by using https inside of onlyoffice machine (not on the reverse proxy) and the reverse proxy is httpd (apache) with https, the issue is also solved, ant0nwax will continue on the other issue report...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Docker-DocumentServer-ONLYOFFICE#206
No description provided.