WebDAV and Cloud ID use IP address instead of domain name

I just installed Nextcloud (using official ZIP file) and ran into the issue that the WebDAV URL and the Federated Cloud ID that are shown by Nextcloud use the IP address + port number instead of my domain name. I.E., Nextcloud suggests the following WebDAV URL (all IP addresses and domain names are anonymized here):

https://333.444.555.888:9999/nextcloud/remote.php/webdav/

However, my Nextcloud instance is well accessible through my domain, therefore the following works perfectly fine:

https://mydomain.com/nextcloud/remote.php/webdav/

How can I get Nextcloud to use the domain name instead of the IP address and port combination?

I think that this should be possible, because my OwnCloud instance, that I run in parallel with almost identical configuration, does in fact display the correct domain name, whereas Nextcloud does not.

I enabled URL rewriting already and my domain name is listed in the config.php. The server name is also defined in the apache2 virtual host config file.

Not sure if this is relevant: My Nextcloud / OwnCloud instances run behind a reverse proxy.

Nextcloud version 15.0.5:
Operating system and version: Ubuntu 18.04
Apache version: 2.4.29
PHP version: 7.2.15

Have a look at this setting:

/**

  • The automatic hostname detection of Nextcloud can fail in certain reverse

  • proxy and CLI/cron situations. This option allows you to manually override

  • the automatic detection; for example www.example.com, or specify the port

  • www.example.com:8080.

*/

‘overwritehost’ => ‘’,

and perhaps the 'overwrite.cli.url' => '', for cron-created mails.