[GH-ISSUE #224] Onlyoffice behind reverse proxy won't work (502 Bad Gateway) #121

Closed
opened 2026-02-26 09:36:39 +03:00 by kerem · 13 comments
Owner

Originally created by @artemis-mike on GitHub (Feb 16, 2020).
Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/224

Do you want to request a feature or report a bug?
It seems like a bug, but mostly I'd just like some help.

My setup

  • Ubuntu 18.04.4 LTS (Bionic Beaver) running
  • docker version 19.03.5, build 633a0ea838 running several containers
  • jwilder/nginx-proxy:0.7.0
  • jrcs/letsencrypt-nginx-proxy-companion:v1.12
  • nextcloud:18.01
  • onlyoffice/documentserver:5.4.2.46
  • and some other containers e.g. wordpress, db-servers, ...

What is the current behavior?
Except onlyoffice everything works like a charm. I got a sub-domain for every outgoing service (wordpress, nextcloud) handled by nginx-proxy. Now I wanted to add the onlyoffice-documentserver to my nextcloud.
I added a block to my docker-compose.yml-file stating
VIRTUAL_HOST=office.my-domain.tld
LETSENCRYPT_HOST=office.my-domain.tld
When I try to connect to onlyoffice in nextcloud it throws
Server error: GET https://office.my-domain.tld/healthcheck resulted in a 502 Bad Gateway response: <html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>ngin (truncated...)...

What is the expected behavior?
If I'm using purely the docker-compose-block of the onlyoffice/documentserver:latest omitting certificates and using plain HTTP it works perfectly and shows the beautiful page stating "Thank you for choosing ONLYOFFICE! Document Server is running [...]"
But including it into the reverse-proxy-environment results in that 502-Error.

DocumentServer Docker tag:
5.4.2.46

Host Operating System:
Ubuntu 18.04.4 LTS (Bionic Beaver) running docker 19.03.5

Docker-Compose-File Entry

#ONLYOffice
  onyloffice:
    restart: always
    stdin_open: true
    tty: true
    depends_on:
      - nginx-proxy
      - encryption-companion
    image: onlyoffice/documentserver:latest
    volumes:
      - './onlyoffice/var/log/onyloffice:/var/log/onyloffice'
      - './onlyoffice/var/www/onyloffice/data:/var/www/onyloffice/data'
    environment:
      - VIRTUAL_HOST=${ONLYOFFICE_HOST}
      - LETSENCRYPT_HOST=${ONLYOFFICE_HOST}
      - JWT_ENABLE=true
      - JWT_SECRET=${ONLYOFFICE_JWT_SECRET}
      - JWT_HEADER=Authorization
    networks:
      - mynetwork

I would prefer to run the documentserver within the single machine hosting everything else over docker. Instead of starting a separate server just for hosting onlyoffice.

Originally created by @artemis-mike on GitHub (Feb 16, 2020). Original GitHub issue: https://github.com/ONLYOFFICE/Docker-DocumentServer/issues/224 **Do you want to request a *feature* or report a *bug*?** It seems like a bug, but mostly I'd just like some help. **My setup** - Ubuntu 18.04.4 LTS (Bionic Beaver) running - docker version 19.03.5, build 633a0ea838 running several containers - jwilder/nginx-proxy:0.7.0 - jrcs/letsencrypt-nginx-proxy-companion:v1.12 - nextcloud:18.01 - onlyoffice/documentserver:5.4.2.46 - and some other containers e.g. wordpress, db-servers, ... **What is the current behavior?** Except onlyoffice everything works like a charm. I got a sub-domain for every outgoing service (wordpress, nextcloud) handled by nginx-proxy. Now I wanted to add the onlyoffice-documentserver to my nextcloud. I added a block to my docker-compose.yml-file stating _VIRTUAL_HOST=office.my-domain.tld_ _LETSENCRYPT_HOST=office.my-domain.tld_ When I try to connect to onlyoffice in nextcloud it throws Server error: `GET https://office.my-domain.tld/healthcheck resulted in a 502 Bad Gateway response: <html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>ngin (truncated...)...` **What is the expected behavior?** If I'm using purely the docker-compose-block of the onlyoffice/documentserver:latest omitting certificates and using plain HTTP it works perfectly and shows the beautiful page stating "Thank you for choosing ONLYOFFICE! Document Server is running [...]" But including it into the reverse-proxy-environment results in that 502-Error. **DocumentServer Docker tag:** 5.4.2.46 **Host Operating System:** Ubuntu 18.04.4 LTS (Bionic Beaver) running docker 19.03.5 **Docker-Compose-File Entry** ``` #ONLYOffice onyloffice: restart: always stdin_open: true tty: true depends_on: - nginx-proxy - encryption-companion image: onlyoffice/documentserver:latest volumes: - './onlyoffice/var/log/onyloffice:/var/log/onyloffice' - './onlyoffice/var/www/onyloffice/data:/var/www/onyloffice/data' environment: - VIRTUAL_HOST=${ONLYOFFICE_HOST} - LETSENCRYPT_HOST=${ONLYOFFICE_HOST} - JWT_ENABLE=true - JWT_SECRET=${ONLYOFFICE_JWT_SECRET} - JWT_HEADER=Authorization networks: - mynetwork ``` I would prefer to run the documentserver within the single machine hosting everything else over docker. Instead of starting a separate server just for hosting onlyoffice.
kerem closed this issue 2026-02-26 09:36:39 +03:00
Author
Owner

@ShockwaveNN commented on GitHub (Feb 17, 2020):

@agolybev could you take a look?

<!-- gh-comment-id:586869260 --> @ShockwaveNN commented on GitHub (Feb 17, 2020): @agolybev could you take a look?
Author
Owner

@effatee commented on GitHub (Mar 7, 2021):

Hi there, did you ever solve this ? (running into the same issue...)

<!-- gh-comment-id:792348282 --> @effatee commented on GitHub (Mar 7, 2021): Hi there, did you ever solve this ? (running into the same issue...)
Author
Owner

@artemis-mike commented on GitHub (Mar 7, 2021):

"Unfortunately" not. I eventually gave up and switched to collabora. It works like a charme.
I host a own Collabora CODE instance as container and connected it to my nextcloud.
The possibilities of collabora are a bit limited compared to onlyoffice. Well, of what I expected of Onlyoffice. I couldn't tell for sure, as I never got it to work at all.

<!-- gh-comment-id:792350290 --> @artemis-mike commented on GitHub (Mar 7, 2021): "Unfortunately" not. I eventually gave up and switched to collabora. It works like a charme. I host a own Collabora CODE instance as container and connected it to my nextcloud. The possibilities of collabora are a bit limited compared to onlyoffice. Well, of what I expected of Onlyoffice. I couldn't tell for sure, as I never got it to work at all.
Author
Owner

@effatee commented on GitHub (Mar 7, 2021):

Thanks for your feedback. Damn frustrating... ;-)

<!-- gh-comment-id:792350597 --> @effatee commented on GitHub (Mar 7, 2021): Thanks for your feedback. Damn frustrating... ;-)
Author
Owner

@socram70 commented on GitHub (Sep 9, 2022):

I did experience the same issues here. I did figure out that the issue is not because of the reverse proxy, but because the server does not seem to listen to all IP addresses. I did map my docker-network-IP-Port 8081 to port 80 of the container (172.20.0.3:8081). However, that does only lead to connection refused if I do use wget in the shell to test it. It is working fine with 127.0.0.1:8081, but this address is somehow not reachable via my nginx-reverse-proxy-container on the same server.

Maybe someone has an idea here? I did change the env-variable for REDIS_SERVER_HOST to 172.20.0.3 already, but this does not help :-(

<!-- gh-comment-id:1241525686 --> @socram70 commented on GitHub (Sep 9, 2022): I did experience the same issues here. I did figure out that the issue is not because of the reverse proxy, but because the server does not seem to listen to all IP addresses. I did map my docker-network-IP-Port 8081 to port 80 of the container (172.20.0.3:8081). However, that does only lead to connection refused if I do use wget in the shell to test it. It is working fine with 127.0.0.1:8081, but this address is somehow not reachable via my nginx-reverse-proxy-container on the same server. Maybe someone has an idea here? I did change the env-variable for REDIS_SERVER_HOST to 172.20.0.3 already, but this does not help :-(
Author
Owner

@agusdomin commented on GitHub (Mar 15, 2023):

Hi, same problem here.
I'm testing a onlyoffice document server hosted in my pc (Ubuntu 20). And i have a nextcloud server in a remote server (Centos 7)

I don't know if the problem come from onlyoffice server (nginx) or nextcloud server.

Someone solved it?

<!-- gh-comment-id:1470377650 --> @agusdomin commented on GitHub (Mar 15, 2023): Hi, same problem here. I'm testing a onlyoffice document server hosted in my pc (Ubuntu 20). And i have a nextcloud server in a remote server (Centos 7) I don't know if the problem come from onlyoffice server (nginx) or nextcloud server. Someone solved it?
Author
Owner

@agusdomin commented on GitHub (Mar 16, 2023):

I solved it, i cant belive what it was.

It was the default port of onlyoffice server, that is 8000, defined in /etc/onlyoffice/documentserver/default.json

"services": { "CoAuthoring": { "server": { "port": 8000, ...

EDIT:

A way to show document server port, on nextcloud server:

sudo -u apache php /var/www/html/nextcloud/occ onlyoffice:documentserver

<!-- gh-comment-id:1471753971 --> @agusdomin commented on GitHub (Mar 16, 2023): I solved it, i cant belive what it was. It was the default port of onlyoffice server, that is 8000, defined in `/etc/onlyoffice/documentserver/default.json` ` "services": { "CoAuthoring": { "server": { "port": 8000, ... ` EDIT: A way to show document server port, on nextcloud server: sudo -u apache php /var/www/html/nextcloud/occ onlyoffice:documentserver
Author
Owner

@just-in-tech commented on GitHub (Sep 8, 2023):

i am having the same issue
i have figure out when i access http://mydomain/healthcheck in a web browser it works no problem but when i use wget it just says server returned error: HTTP/1.1 502 Bad Gateway and same with nextcloud i was think it could be something like http versions but i don't know

edit just confirmed web browser is using HTTP/2 but wget is using HTTP/1.1

<!-- gh-comment-id:1710943200 --> @just-in-tech commented on GitHub (Sep 8, 2023): i am having the same issue i have figure out when i access http://mydomain/healthcheck in a web browser it works no problem but when i use wget it just says server returned error: HTTP/1.1 502 Bad Gateway and same with nextcloud i was think it could be something like http versions but i don't know edit just confirmed web browser is using HTTP/2 but wget is using HTTP/1.1
Author
Owner

@sdk1-kod commented on GitHub (Dec 20, 2023):

I solved it, i cant belive what it was.

It was the default port of onlyoffice server, that is 8000, defined in /etc/onlyoffice/documentserver/default.json

"services": { "CoAuthoring": { "server": { "port": 8000, ...

EDIT:

A way to show document server port, on nextcloud server:

sudo -u apache php /var/www/html/nextcloud/occ onlyoffice:documentserver

how did you solve it?

<!-- gh-comment-id:1863802536 --> @sdk1-kod commented on GitHub (Dec 20, 2023): > I solved it, i cant belive what it was. > > It was the default port of onlyoffice server, that is 8000, defined in `/etc/onlyoffice/documentserver/default.json` > > `"services": { "CoAuthoring": { "server": { "port": 8000, ...` > > EDIT: > > A way to show document server port, on nextcloud server: > > sudo -u apache php /var/www/html/nextcloud/occ onlyoffice:documentserver how did you solve it?
Author
Owner

@socram70 commented on GitHub (Dec 20, 2023):

@thesorskod you can do this by either mounting the config file and place your own file there (I wouldn't recommend this) or just map the port 8000 to anything you like via Docker.

<!-- gh-comment-id:1863959146 --> @socram70 commented on GitHub (Dec 20, 2023): @thesorskod you can do this by either mounting the config file and place your own file there (I wouldn't recommend this) or just map the port 8000 to anything you like via Docker.
Author
Owner

@mwneuendorf commented on GitHub (Feb 15, 2024):

I'm not sure what update changed things. My nginx-proxy config was working before but now it's required to turn on Websockets Support in nginx-proxy.

<!-- gh-comment-id:1945214790 --> @mwneuendorf commented on GitHub (Feb 15, 2024): I'm not sure what update changed things. My nginx-proxy config was working before but now it's required to turn on Websockets Support in nginx-proxy.
Author
Owner

@igwyd commented on GitHub (Feb 15, 2024):

Hello, we have some examples for the reverse proxy settings, we recomend use it https://helpcenter.onlyoffice.com/installation/docs-community-proxy.aspx

<!-- gh-comment-id:1945627313 --> @igwyd commented on GitHub (Feb 15, 2024): Hello, we have some examples for the reverse proxy settings, we recomend use it https://helpcenter.onlyoffice.com/installation/docs-community-proxy.aspx
Author
Owner

@Rita-Bubnova commented on GitHub (Feb 15, 2024):

This doesn't look like an issue, so I'll convert to a discussion.

<!-- gh-comment-id:1945775269 --> @Rita-Bubnova commented on GitHub (Feb 15, 2024): This doesn't look like an issue, so I'll convert to a discussion.
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#121
No description provided.