Nextcloud behind Reverse Proxy with SNI

We are using Cloudflare as reverse proxy and multiple FQDNs. At the side, where the nextcloud server is, there is only on public ip address.

Both FQDNs are in ‘trusted_domains’ in config.php. That makes it possible to view the the nextcloud instance with both FQDNs.

Now comes the reverseproxy in the game:

User opens FQDN1 or FQDN2 in browser,
DNS locates to reverse proxy,
in case of FQDN1 Reverseproxy server contacts NAT-Firewall Port 4061 (443 is already in use), NAT target will be private ip address on port 443 of nextcloud server.
in case of FQDN2 Reverseproxy server contacts NAT-Firewall Port 4062 (443 is already in use), NAT target will be private ip address on port 443 of nextcloud server.

If I type in FQDN/dashboard in the browser it works
If I type in FQDN only, the browser tries to redirect to FQDN1:4061 / FQDN2:4062

I have resolved that by using the parameter ‘overwritehost’. But I cannot only specify a Port in that parameter. So I inserted FQDN1:443.

That works now perfect for users, which are trying to open FQDN1. But if FQDN2 is inserted in the Browser, this results in redirecting to FQDN1. The users are confused of the new address in the browser and won’t login.

How can I only overwrite the port to 443 and leave the origin hostname as is?

Nextcloud version (20.0.4):
Operating system and version (Synology DSM 6.23):
Apache or nginx version (Apache 2.4):
PHP version (7.3):