Today i have looked into the problem a little further. I found out, that the nextcloud is working with the changed port. But my firefox does not keep the custom port number. So when the nextcloud wants to redirect me from "xyz.dyndns.com:145/nextcloud" to "xyz.dyndns.com:145/nextcloud/index.php/login" the port number is lost and it redirects to "xyz.dyndns.com/nextcloud/index.php/login" instead. If I manually add the port number afterwards everything works as expected and i can log in.
Following your suggestion, I changed the port number in the config.php. Then I get a message, that I access the cloud on an untrusted domain, because the container still thinks it is on the usual port 443.
Do you have any ideas how to fix this?
Edit: I found a working solution.
If I set the value
"proxy_set_header Host $host:$server_port;"
in the file proxy.conf file of nginx to
"proxy_set_header Host $host:145;"
the port number no longer gets lost. It is a little messy I guess, but for now I am fine with this.