After some testing, it seems that even if I set the values for Traefik mentioned in the thread (adapted to 172.34.0.0/16 in my case), it does not set this header. In fact, even if I set --entrypoints.lansecure.forwardedHeaders.insecure=true, Nextcloud still just sees the IP of Traefik.
I guess I will have to double check my Traefik setup or maybe my router. Thanks for pointing me in that direction.