Plex API - Sessions Status not honoring X-Forwarded-For & X-Real-IP with IPv6 clients

+1 from me too.

I have tried quite a few ways to make this work with local IPv4 clients (not using IPv6) but nothing did the trick. I even tried to fool Plex into thinking any connection is non-local by setting “LAN Networks” to a network neither the server nor any local client is in.
I did, however, find that Plex does not seem to check whether the traffic comes from the same network the server is in. It only checks if it comes from a private IP (RFC 1918). I tested this by having a client from another subnet of my network access the Plex server. I set that network to 8.8.8.0/24 (a public IP range) for testing and suddently Plex thought of the client as a remote client and used the X-Forwarded-For ip address. Setting it to 192.168.178.0/24 (a private IP range) resulted in the usual behavior of Plex using the reverse proxies’ ip address instead of X-Forwarded-For.

Since nobody has posted any logs yet, here’s one set for a local client through the reverse proxy:

Oct 07, 2018 17:29:26.779 [] DEBUG - Request: [rev.erse.pro.xy:59100 (Subnet)] GET [...]
Oct 07, 2018 17:29:26.779 [] VERBOSE -  * Host => custom.domain:443
Oct 07, 2018 17:29:26.779 [] VERBOSE -  * X-Real-IP => lo.cal.cli.ent
Oct 07, 2018 17:29:26.779 [] VERBOSE -  * X-Forwarded-For => lo.cal.cli.ent
Oct 07, 2018 17:29:26.779 [] VERBOSE -  * Connection => Upgrade

And one for a remote client through the same reverse proxy:

Oct 07, 2018 17:35:10.544 [] DEBUG - Request: [rev.erse.pro.xy:59264 (WAN)] GET [...]
Oct 07, 2018 17:35:10.544 [] VERBOSE -  * Host => custom.domain:443
Oct 07, 2018 17:35:10.544 [] VERBOSE -  * X-Real-IP => rem.ote.cli.ent
Oct 07, 2018 17:35:10.544 [] VERBOSE -  * X-Forwarded-For => rem.ote.cli.ent
Oct 07, 2018 17:35:10.544 [] VERBOSE -  * Connection => Upgrade
[...]
Oct 07, 2018 17:53:37.121 [] DEBUG - Using X-Forwarded-For: rem.ote.cli.ent as remote address

The last line seems to be the key since it only appears for remote clients.

2 Likes