OnlyOffice working when accessing via IP but not via domain

Hello everyone,

I am quite new to this community, but not to Nextcloud itself. I’ve been running Nextcloud on my homeserver for years, but recently started renting a bigger VPS where I could provide multiple people with.

I’ve installed Nextcloud 18 with docker, which of course also brought OnlyOffice with it. All works fine at this point.

I am using Apache to proxy the nextcloud-instance to port 443 and thereby my domain, however when accessing nextcloud via this domain, onlyoffice instantly stops working (silently fails to open documents).

Changing the URL in the onlyoffice config-section of nextcloud also does appear to help…

I am suspecting an issue with the proxy in apache, but cannot really find anything here.

Here’s relevant parts of the config:

´´´
<VirtualHost my_ip:443 [my_ipv6]:443>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/nextcloud
    ServerName "domain.tld"
    ServerAlias "sub.domain.tld"

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # Nextcloud - when run via docker...
    ProxyPreserveHost On
    ProxyPass         / http://0.0.0.0:8081/
    ProxyPassReverse  / http://0.0.0.0:8081/

    SSLCertificateFile /etc/letsencrypt/live/sub.domain.tld/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/sub.domain.tld/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
```

I hope anyone can point me in the right direction! Kind regards,
JayVii

Edit: after when using “ProxyPreserveHost On” in apache, OnlyOffice does not fail silently, but instead opens and talks about “unknown error”: