I was wrong. This must be a problem with Nextcloud.
I spun up a whoami container and the header is correct. In another container that logs the client IP the IP is correct as well.
Apologies for the noise - I thought that the tcpdump test was enough to confirm that the IP is incorrect but I will deep dive into the Nextcloud container to understand where the problem is.
The GitHub issue is closed as well.