Collabora /hosting/discovery gives 502 bad gateway (with nginx reverse proxy)

I’m using docker image collabora/code behind nginx docker image. But I when I try to add the collabora domain on my nextcloud instance, I’m getting 502 bad gateway errors.

My docker compose file:

 version: '3'
 services:
   nginx: 
     image: nginx:latest
     container_name: nginx_reverse_proxy
     volumes:
       - ./nginx.conf:/etc/nginx/nginx.conf
       - /etc/letsencrypt/:/etc/letsencrypt/
       - ./access_log:/var/log/nginx/hts-il-db-lb-access.log
       - ./error_log:/var/log/nginx/hts-il-db-lb-error.log
     ports:
       - 80:80
       - 443:443
   collabora:
     image: collabora/code
     container_name: collabora
     ports:
       - 9980:9980
     environment:
       - domain=mydomain1.com|mydomain2.com
     restart: always
 networks:
   default:
     external: true
     name: nginx-network

And my nginx.conf file (copied from here):

 events {}
 http {
   server {
     server_name collabora.mydomain1.com;
     
     listen 443 ssl;
     
     ssl_certificate /etc/letsencrypt/live/collabora.mydomain1.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/collabora.mydomain1.com/privkey.pem;
    
 
     # static files
     location ^~ /loleaflet {
         proxy_pass http://localhost:9980;
         proxy_set_header Host $http_host;
     }
 
     # WOPI discovery URL
     location ^~ /hosting/discovery {
         proxy_pass http://localhost:9980;
         proxy_set_header Host $http_host;
     }
 
     # Capabilities
     location ^~ /hosting/capabilities {
         proxy_pass http://localhost:9980;
         proxy_set_header Host $http_host;
     }
 
     # main websocket
     location ~ ^/lool/(.*)/ws$ {
         proxy_pass http://localhost:9980;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "Upgrade";
         proxy_set_header Host $http_host;
         proxy_read_timeout 36000s;
     }
 
     # download, presentation and image upload
     location ~ ^/lool {
         proxy_pass http://localhost:9980;
         proxy_set_header Host $http_host;
     }
 
     # Admin Console websocket
     location ^~ /lool/adminws {
         proxy_pass http://localhost:9980;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "Upgrade";
         proxy_set_header Host $http_host;
         proxy_read_timeout 36000s;
     } 
 
    error_log /var/log/nginx/hts-il-db-lb-error.log debug;
   }
 }

when i try to access collabora.mydomain1.com/hosting/discovery I get 502 Bad gateway in my browser, and on my collabora server instance, the terminal outputs: "GET /hosting/discovery HTTP/1.1" 502 157 "-" "Nextcloud Server Crawler"

Any suggestions? Thanks!

Solved following this stackoverflow answer

Basically:
- Need to add volume mount (loolwsd.xml can be copied from docker container, i.e., docker cp collabora:/etc/loolwsd/loolwsd.xml .)

./collabora/loolwsd.xml:/etc/loolwsd/loolwsd.xml and edit the loolwsd.xml content

    <ssl desc="SSL settings">
            <enable type="bool" desc="Controls whether SSL encryption between browser and loolwsd is enabled (do not disable for production deployment). If default is false, must first be compiled with SSL support to enable." default="true">false</enable>
            <termination desc="Connection via proxy where loolwsd acts as working via https, but actually uses http." type="bool" default="true">true</termination>
(source: https://stackoverflow.com/questions/66420231/mixed-content-error-with-collabora-code-nextcloud-traefik-reverse-proxy-via/68239517#68239517)