toomuchio / plex-nginx-reverseproxy

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

Reporting 127.0.0.1 #38

Closed Animosity022 closed 5 years ago

Animosity022 commented 5 years ago

This isn't a plexpy issue:

https://github.com/toomuchio/plex-nginx-reverseproxy/issues/36

I can see it the regular plex UI. Can you tell me how you are trying to reproduce it? I opened a thread on plex forums as well. I can reproduce this with nginx and with caddy so I want to confirm it isn't an issue with something else I might be doing.

camjac251 commented 5 years ago

I had this similar issue before but never tried to fix it. It would happen on PMP but not on PHT (has happened for that long for me) or the Plex for Kodi app. I do remember reading somewhere that you'd need to recompile nginx with http_realip_module if it isn't already installed.

I'd recommend maybe seeing if nginx -V shows the module. If not try these links, they both contain the same info but in a different format which might be helpful

https://www.globo.tech/learning-center/x-forwarded-for-ip-nginx/ https://ypereirareis.github.io/blog/2017/02/15/nginx-real-ip-behind-nginx-reverse-proxy/

Hope that helps :)

Animosity022 commented 5 years ago

Is your internal network something private as well and it shows properly? Like the 192.168.0/10. or 172.16 ranges?

I can see nginx/caddy are passing the right IP in the debug logs via plex as I can tell it works if I can my internal IPs.

I posted on Plex but they weren't too helpful.

https://forums.plex.tv/t/nginx-proxy-x-forwarded-for-ignored-for-192-168-10-0-private-addresses/303138/10

I did try with realip and some config there, but since it was passing the x-forward properly, I really don't think it's a proxy since it's repeatable on both nginx and caddy.

I was more curious if you are using something private and it is working, which leads me to something else in my config elsewhere.

camjac251 commented 5 years ago

When I was running CF with Nginx over the CDN, it was with Ubuntu on a public network. My IP would be 127.0.0.1. Have you tried something like this in the nginx config

set_real_ip_from 192.168.0/10;
real_ip_header X-Forwarded-For;
Animosity022 commented 5 years ago

Yep. I tried with and without that.

When I do the plex debug logs, I can see the proper IP is being passed:

Aug 31, 2018 13:41:22.296 [0x7f1bc3ffd700] VERBOSE -  * X-Forwarded-For => 10.0.8.6

That would be the same when I was 192.168.1.0/24 or 172.16 space. I re-ip-ed and tried all that and with the same NGINX or Caddy config, the IP comes through except if I use a private address space.

My thought was plex was ignoring that for whatever reason, but they don't seem to able to confirm or deny that as the debug logs from Plex show the X-Forwarded-For IP properly.

ghost commented 5 years ago

I raised this same issue a while back, but the topic was closed shortly thereafter. I did some research on my own and discovered it to be a plex issue rather than an nginx issue. Plex dev's have been aware of the problem for over a year so a fix is not likely anytime soon.

https://forums.plex.tv/t/plex-api-sessions-status-not-honoring-x-forwarded-for-x-real-ip-with-ipv6-clients/175705/24

Animosity022 commented 5 years ago

Yeah, I saw that post as well and that was related to IPV6 though as it is definitely not honoring that.

It seems it is also not honoring any private IP range though, which is unfortunate.

I was just curious if anyone had it working although I think it's a plex bug.

Animosity022 commented 5 years ago

I’ll close it out as doesn’t seem like a Plex issue