Matomo in Hybrid Environment Reverse-Proxy with IPv4 and direct Connection with IPv6

Hi there,

First Post in this forum, so please feel free to push my post into the right category if I misplaced it.

I am currently using Matomo on a small Website with Wordpress. Currently every is working fine on a regular VHost Basis with one IPv6 and one IPv4 Address registered

As I needed to push my setup more forward to IPv6 I found a solution that I think works pretty well without breaking Support for visitors not using IPv6 yet. As I am currently “playing” with the possibilities that open up with IPv6 I am also thinking about possibly splitting up the setup for different services by using the Option to route traffic to different subnets / hosts (especially I am thinking about using Docker instead of VHosts for future projects - one IPv6-Subnet (eg. /72 or even /80 per project).

So here is my current idea / setup.
If a visitor uses IPv6 to connect to the server, the DNS will tell him the current IPv6 Address to access the site - very easy and convenient to administrate, every VHost will just listen to its dedicated IPv6-Address - no matter if its native VHost in Apache or some other Host in any of the subnets.

If a visitor uses IPv4, Apache will first act as a reverse Proxy based on the requested ServerName and then hand of the request to the corresponding IPv6-Host (which may be the same server process or one running in a subnet on a different machine).

I tested the setup so far with a playground environment and it works as expected. However I am currently worried about Matomo in this scenario:
To detect the remote IP, you may add configuration values to use the X-Forwarded-For header, which works fine for the IPv4 case, but breaks when a client uses IPv6 and vice versa.

I did not do a dive into the code of Matomo yet, so I am not sure if it is possible to have a sort “order” to try: if set, use X-Forwarded-For (IPv4-Case with ReverseProxy) otherwise use Remote-IP given in Header (IPv6 native).
Has anybody already tried out such a scenario or am I just heading in the wrong direction, worrying to much about an already solved problem?

Any ideas, comments and of course help is greatly appreciated.