Nextcloud Office can't connect to CODE behind reverse proxy: Requesting address is denied

I’m facing a similar issue. I’m trying to set up NextCloud and Collabora on the same domain, but using two different ports.

NextCloud indicates that the Collabora Online server is reachable, and I can successfully curl from the client to NextCloud, as well as from NextCloud to Collabora and vice versa.

Despite this, I’m unable to edit files. The Collabora logs show the following error:
[ websrv_poll ] WRN convert-to: Requesting address is denied: NextCloudIP| wsd/ClientRequestDispatcher.cpp:493

I’m unsure of the root cause, but suspect it may be related to the reverse proxy configuration, NextCloud settings, or Collabora settings.

Here’s an overview of my setup. I’m using Caddy as a reverse proxy.
In docker-compose.yaml, I have the following configuration for Caddy and Collabora:

caddy:
    container_name: reverse-proxy
    image: caddy:2
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
      - 9985:9985
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy_v2_data:/data
      - ./caddy_v2_config:/config
    networks:
      - nextcloud_network
collabora: 
    image: collabora/code
    container_name: collabora_app
    environment:
      - domain=NEXTCLOUDDOMAIN\\.dedyn\\.io
      - aliasgroup1=NEXTCLOUDDOMAIN.dedyn.io
      - server_name=https://NEXTCLOUDDOMAIN.dedyn.io:9985
      - username=${COLLABORA_USERNAME}
      - password=${COLLABORA_PASSWORD}
      - extra_params=--o:ssl.enable=false --o:ssl.termination=true --o:net.proto=IPv4
    cap_add: 
      - MKNOD
    ports:
      - "9980:9980"
    volumes:
      - ./collabora_setup/coolwsd/coolwsd.xml:/etc/coolwsd/coolwsd.xml
    networks:
      - nextcloud_network
    restart: always

My Caddyfile is as follows:

https://NEXTCLOUDDOMAIN.dedyn.io:443 {
        reverse_proxy nextcloud-web:80

        # Set headers
        header /* {
                Strict-Transport-Security "max-age=15552000;"
        }

        # Rewrite rules
        rewrite /.well-known/carddav /remote.php/dav
        rewrite /.well-known/caldav /remote.php/dav
        rewrite /.well-known/webfinger /index.php/.well-known/webfinger
        rewrite /.well-known/nodeinfo /index.php/.well-known/nodeinfo
}

https://NEXTCLOUDDOMAIN.dedyn.io:9985 {
        reverse_proxy collabora_app:9980
        reverse_proxy /cool/* http://127.0.0.1:9980 {
                header_up Host {host}
                header_up X-Real-IP {remote}
                header_up Connection "Upgrade"
                header_up Upgrade websocket
        }
}

And in coolwsd.xml file, I’ve modified the server_name:
<server_name desc=“External hostname:port of the server running coolwsd. If empty, it’s derived from the request (please set it if this doesn’t work). May be specified when behind a reverse-proxy or when the hostname is not reachable directly.” type=“string” default=“”>NEXTCLOUDDOMAIN.dedyn.io:9985</server_name>

I also adjusted the SSL settings:

<enable type="bool" desc="Controls whether SSL encryption between coolwsd and the network 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 coolwsd acts as working via https, but actually uses http." type="bool" default="true">true</termination>
And the username and password for the admin console.

I would appreciate any suggestions or guidance on how to resolve this issue. Thanks in advance!