COLLABORA Code & Nextcloud - Reverse proxy

1. The problem I’m having:

I have successfully deployed a nextcloud installation with docker-compose and caddy. To use the Nextcloud Office, i’m trying to set up a COLLABORA Code server, using the official image.

2. Error messages and/or full log output:

Even tho I tried many ways, I still cannot access my collaborate server, it still return a 502 error.

{“level”:“debug”,“ts”:1695721116.5628216,“logger”:“http.handlers.reverse_proxy”,“msg”:“upstream roundtrip”,“upstream”:“code:9980”,“duration”:0.001511005,“request”:{“remote_ip”:“89.90.105.181”,“remote_port”:“50031”,“proto”:“HTTP/2.0”,“method”:“GET”,“host”:“collabora.37crea.com”,“uri”:“/”,“headers”:{“Cache-Control”:[“max-age=0”],“User-Agent”:[“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36”],“Sec-Fetch-Site”:[“none”],“Sec-Fetch-Mode”:[“navigate”],“Accept-Language”:[“fr-FR,fr;q=0.7”],“Sec-Ch-Ua-Platform”:[“"Windows"”],“Upgrade-Insecure-Requests”:[“1”],“Sec-Gpc”:[“1”],“Accept”:[“text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8”],“Accept-Encoding”:[“gzip, deflate, br”],“Sec-Ch-Ua”:[“"Brave";v="117", "Not;A=Brand";v="8", "Chromium";v="117"”],“X-Forwarded-Proto”:[“https”],“X-Forwarded-Host”:[“collabora.37crea.com”],“Sec-Fetch-User”:[“?1”],“Sec-Fetch-Dest”:[“document”],“Sec-Ch-Ua-Mobile”:[“?0”],“X-Forwarded-For”:[“89.90.105.181”]},“tls”:{“resumed”:false,“version”:772,“cipher_suite”:4865,“proto”:“h2”,“server_name”:“collabora.37crea.com”}},“error”:“EOF”}

As far as I understand, there’s a problem with the reverse proxy. But I don’t get it.
The domain and subdomain points to the correct IP.

3. Caddy version:

Latest version

4. How I installed and ran Caddy:

I run caddy over docker-compose :

c. Service/unit/compose file:


version: '3.8'

services:
  caddy:
    image: caddy
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
    ports:
      - 80:80
      - 443:443
      - 9980:9980

  nextcloud_db:
    image: mariadb
    container_name: nextcloud_db
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    volumes:
      - ./db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=***  
      - MYSQL_DATABASE=***
      - MYSQL_USER=***
      - MYSQL_PASSWORD=***

  nextcloud_app:
    image: nextcloud
    restart: always
    links:
      - nextcloud_db
    volumes:
      - ./data:/var/www/html
    environment:
      - MYSQL_HOST=***  
      - MYSQL_DATABASE=***  
      - MYSQL_USER=*** 
      - MYSQL_PASSWORD=***  

  code:
    image: collabora/code:latest
    restart: always
    environment:
      -  password=${COLLABORA_PASSWORD}
      -  username=${COLLABORA_USERNAME}
      -  domain=${COLLABORA_DOMAIN}
    ports:
      - 9980:9980

d. My complete Caddy config:

{
        debug
}

https://docs.37crea.com { #THIS PART WORK FINE
    encode gzip
    reverse_proxy nextcloud_app:80

    header {
        Strict-Transport-Security "max-age=15768000;includeSubDomains;preload"
    }

    redir /.well-known/carddav /remote.php/carddav 301
    redir /.well-known/caldav /remote.php/caldav 301
}

collabora.37crea.com { #THIS PART DOESN'T WORK, ERROR 502
  encode gzip

  reverse_proxy code:9980
}

5. Links to relevant resources:

I tried the examples from that topic, without success : Example: Collabora CODE

It seems like collabora is serving HTTPS on that port, not HTTP. You probably need to use a different port for proxying over HTTP. That should be covered in their docs.

They mention the 9980 port in their docs, that’s what makes it weird.