toomuchio / plex-nginx-reverseproxy

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

Fix incorrect client IP being passed to Plex #34

Closed jamesonp closed 6 years ago

jamesonp commented 6 years ago

Fix incorrect real IP address being passed to Plex.

If users have the ngx_http_realip_module enabled, the wrong IP address may be passed to Plex and therefore reports the Nginx reverse proxy as the client IP. Adding $realip_remote_addr fixes this.

toomuchio commented 6 years ago

I don't exactly see the point in merging this ngx_http_realip_module isn't enabled by default or even compiled by default.

And I'm not entirely sure what this is going to do if you don't have that mod installed, which is probably the case for most people.

The proxy runs locally as well so nobody can falsify headers if you use realip you need to set "$http_x_forwarded_for,$realip_remote_addr" as you have If not using it you use $proxy_add_x_forwarded_for" OR "$http_x_forwarded_for,$remote_addr"

toomuchio commented 6 years ago

Might add a note but not making this the default, people really don't need to be spoon fed so much if somebody compiled nginx with realip they should know to fix this themselves I'd expect.

jamesonp commented 6 years ago

This came included with my install from the official Nginx Ubuntu repo:

deb http://nginx.org/packages/mainline/ubuntu/ artful nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ artful nginx
redacted@redacted:~# nginx -v
nginx version: nginx/1.13.12

redacted@redacted:~# 2>&1 nginx -V | tr -- - '\n' | grep real
http_realip_module
stream_realip_module

redacted@redacted:~# apt list nginx
Listing... Done
nginx/stable,now 1.13.12-1~artful amd64 [installed]
toomuchio commented 6 years ago

Yes if you add the nginx repo but if you use the one in the ubuntu repo it doesn't have it, which most people use.

jamesonp commented 6 years ago

Fair enough

toomuchio commented 6 years ago

Note has been added https://github.com/toomuchio/plex-nginx-reverseproxy/commit/5e3bb0966eebc1d6633617dac04701044b1a272c#diff-daaf2fceca49ed034eace91c4e875653

Thanks for informing me