# from: collabora/code:24.04.4.1.1
docker-image: docker.0k.io/collabora:240404.1.1

docker-compose:
  cap_add:
  - MKNOD


uses:
  nextcloud-app:
    #constraint: required | recommended | optional
    #auto: pair | summon | none ## default: pair
    constraint: required
    auto: pair
    solves:
      server: "document server"

  web-proxy:
    #constraint: required | recommended | optional
    #auto: pair | summon | none ## default: pair
    constraint: required
    auto: summon
    solves:
      proxy: "Public access"
    default-options:
      target: !var-expand ${MASTER_BASE_SERVICE_NAME}:9980
      apache-custom-rules:
        - !var-expand |
          # From: https://help.nextcloud.com/t/how-to-install-collabora-in-docker-with-nextcloud-23/133730
          # Encoded slashes need to be allowed
          AllowEncodedSlashes NoDecode

          # Container uses a unique non-signed certificate
          # SSLProxyEngine On
          # SSLProxyVerify None
          # SSLProxyCheckPeerCN Off
          # SSLProxyCheckPeerName Off

          # keep the host
          ProxyPreserveHost On

          # static html, js, images, etc. served from coolwsd
          # browser is the client part of Collabora Online
          ProxyPass           /browser http://${MASTER_BASE_SERVICE_NAME}:9980/browser retry=0
          ProxyPassReverse    /browser http://${MASTER_BASE_SERVICE_NAME}:9980/browser

          # WOPI discovery URL
          ProxyPass           /hosting/discovery http://${MASTER_BASE_SERVICE_NAME}:9980/hosting/discovery retry=0
          ProxyPassReverse    /hosting/discovery http://${MASTER_BASE_SERVICE_NAME}:9980/hosting/discovery

          # Capabilities
          ProxyPass           /hosting/capabilities http://${MASTER_BASE_SERVICE_NAME}:9980/hosting/capabilities retry=0
          ProxyPassReverse    /hosting/capabilities http://${MASTER_BASE_SERVICE_NAME}:9980/hosting/capabilities

          # Main websocket
          ProxyPassMatch      "/cool/(.*)/ws$"      ws://${MASTER_BASE_SERVICE_NAME}:9980/cool/\$1/ws nocanon

          # Admin Console websocket
          ProxyPass           /cool/adminws ws://${MASTER_BASE_SERVICE_NAME}:9980/cool/adminws

          # Download as, Fullscreen presentation and Image upload operations
          ProxyPass           /cool http://${MASTER_BASE_SERVICE_NAME}:9980/cool
          ProxyPassReverse    /cool http://${MASTER_BASE_SERVICE_NAME}:9980/cool

          # Compatibility with integrations that use the /lool/convert-to endpoint
          ProxyPass           /lool http://${MASTER_BASE_SERVICE_NAME}:9980/cool
          ProxyPassReverse    /lool http://${MASTER_BASE_SERVICE_NAME}:9980/cool