Hello,
I would like to share my findings in case it helps someone else.
Environment
- Ubuntu 24.04.4 LTS
- Docker Engine Community 29.6.1
- Docker Compose
- Nextcloud ( Docker image: nextcloud:34.0.1-apache)
- Collabora CODE 26.04.2.2.1 (Docker image: collabora/code:26.04.2.2.1)
- Nginx reverse proxy
Collabora configuration:
collabora:
image: collabora/code:26.04.2.2.1
environment:
cert_domain: collabora[.]example[.]com
domain: nextcloud\\.example\\.com
extra_params: --o:ssl.enable=false --o:ssl.termination=true
Nginx configuration:
location / {
proxy_pass http://collabora:9980;
}
Symptoms
--------
Nextcloud Office reported that it could not connect to the Collabora server.
Accessing the Collabora URL through nginx returned:
502 Bad Gateway
Nginx logs contained:
upstream prematurely closed connection while reading response header from upstream
Investigation
-------------
The container appeared healthy:
docker inspect collabora --format=‘{{.State.Health.Status}}’
Result:
healthy
Collabora logs showed:
Ready to accept connections on port 9980.
Network connectivity was fine:
nc -vz collabora 9980
Result:
Connected to collabora 9980
However:
curl [http] ://collabora:9980/hosting/discovery
returned:
Empty reply from server
I then tested HTTPS directly:
curl -vk [https] ://collabora:9980/hosting/discovery
This returned a valid WOPI discovery XML document and established a TLS connection using a self-signed certificate generated by Collabora.
Root Cause
----------
Although the container was configured with:
extra_params: --o:ssl.enable=false --o:ssl.termination=true
CODE 26.04.2.2.1 was still serving HTTPS on port 9980.
Because nginx was configured with:
proxy_pass [http]://collabora:9980;
there was a protocol mismatch:
Nginx (HTTP) → Collabora (HTTPS)
which caused:
- Empty reply from server
- upstream prematurely closed connection
- 502 Bad Gateway
Solution
--------
I changed the nginx upstream to HTTPS:
location / {
proxy_pass [https]://collabora:9980;
proxy_http_version 1.1;
proxy_ssl_verify off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_read_timeout 3600;
proxy_connect_timeout 3600;
}
Result
------
After restarting nginx:
- [https] ://collabora.example.com/ worked correctly
- /hosting/discovery was reachable
- Nextcloud reported:
“Collabora Online server is reachable”
- Documents opened successfully in Collabora Online
One thing that confused me during troubleshooting:
CODE 26.04.2.2.1 appeared to be serving HTTPS on port 9980 even though I had configured:
--o:ssl.enable=false --o:ssl.termination=true
The issue was resolved by changing the nginx upstream from HTTP to HTTPS, so I’m wondering whether I misunderstood how these parameters are intended to work, or whether something has changed in recent releases.
Thank you.