toomuchio / plex-nginx-reverseproxy

Configuration to serve Plex Media Center https://plex.tv using Nginx https://nginx.com
663 stars 94 forks source link

External clients reported as 127.0.0.1 #16

Closed ghost closed 7 years ago

ghost commented 7 years ago

Since setting up the reverse proxy in front of Plex, a few of my external clients are being reported as 127.0.0.1 when I look through Plexpy. (Xbox One, Chromecast, iOS (iPhone/iPad), Safari/Chrome Web)

I thought maybe those clients were indirectly connected to the server using Plex relay but i’ve investigated, and this is definitely not the case…I also tried adding all my LAN internal IP’s / Subnets in the PMS server “network” settings hoping this would help the server differentiate internal and external clients but that didn’t do the trick.

Any idea what i’m doing wrong?

hjone72 commented 7 years ago

Is the reverse proxy you're using on the same server as PMS?

I ran into the same issue a while back. http://forums.plex.tv/discussion/222469/x-forwarded-for#latest

As a summary for non plex pass members.

For this to work, the requester's remote address must be a private address (e.g. your router's LAN address), and the X-Forwarded-For address must be a non-private address (e.g. something on the WAN).

Basically, if you're reverse proxying Plex traffic for the IP to be correct the final reverse proxy must be 127.0.0.1.

ghost commented 7 years ago

Yes, the reverse proxy is on the same server as PMS. I just went through that plex thread and i'm not quite following what the problem is.

hjone72 commented 7 years ago

Could you please enable debug logging on your Plex server and have a look in the logs for the following entry: Using X-Forwarded-For: XXX.XXX.XXX.XXX as remote address

ghost commented 7 years ago

Apr 11, 2017 15:53:03.167 DEBUG Using X-Forwarded-For: 98.113.39.XX as remote address

It is showing my the public IP addresses of the last connected external client.

hjone72 commented 7 years ago

PlexPy reports what Plex tells it. If Plex thinks your ip is as mentioned above then that is what it will be reporting.

try going here while something is playing. It should show you what plexpy is seeing.

https://plex.yourdomain.com/status/sessions?X-Plex-Token=PLEX_TOKEN

ghost commented 7 years ago

Yup. So the X-Forwarded For address is public but the player address is local. This is strange indeed.

<Player address="127.0.0.1" device="iPhone" machineIdentifier="XXXXX-XXXX-XXXX-XXXX" model="9,2" platform="iOS" platformVersion="10.3.1" product="Plex for iOS" profile="iOS" remotePublicAddress="127.0.0.1" state="playing" title="XXXX" vendor="Apple" version="4.10" local="0" userID="1"/>

ghost commented 7 years ago

Thoughts?

hjone72 commented 7 years ago

Very strange. To my knowledge if Plex is displaying that XFF header Apr 11, 2017 15:53:03.167 DEBUG Using X-Forwarded-For: 98.113.39.XX as remote address then it is reporting that IP as your IP. There is no other reason why it should be different.

I'm running the same config posted here so as long as your are too (I'm assuming you are) I don't think its a config issue. Might have to make a post on Plex forums or consult the expert @toomuchio 😄

EDIT: Maybe verbose logging will show something more useful?

toomuchio commented 7 years ago

No idea, if you've used my config verbatim there shouldn't be issues, maybe your Plex is really out of date? Check your debug logs it should show the X-Forwarded-For header being accepted. My guess your Plex is out of date or you modified the configuration.