-
-
Save ometa/654376bf0e12e6131f2b809b3dc0f151 to your computer and use it in GitHub Desktop.
# This example assumes the NGINX proxy is on the same host as the Plex Media Server. | |
# To configure Plex Media Server to serve requests without requiring authentication, | |
# ensure that your LAN subnet is correctly added to the advanced server setting called | |
# "List of IP addresses and networks that are allowed without auth". Example: | |
# 192.168.0.1/24 | |
upstream plex-upstream { | |
server 127.0.0.1:32400; | |
} | |
server { | |
listen 80; | |
server_name plex tv plex.example.com tv.example.com; | |
location / { | |
# If a request to / comes in, 301 redirect to the main plex page, | |
# but only if it doesn't contain the X-Plex-Device-Name header or query argument. | |
# This fixes a bug where you get permission issues when accessing the web dashboard. | |
set $test ""; | |
if ($http_x_plex_device_name = '') { | |
set $test A; | |
} | |
if ($arg_X-Plex-Device-Name = '') { | |
set $test "${test}B"; | |
} | |
if ($test = AB) { | |
rewrite ^/$ http://$http_host/web/index.html; | |
} | |
proxy_redirect off; | |
proxy_buffering off; | |
# Spoof the request as coming from ourselves since otherwise Plex will block access, e.g. logging: | |
# "Request came in with unrecognized domain / IP 'tv.example.com' in header Referer; treating as non-local" | |
proxy_set_header Host $server_addr; | |
proxy_set_header Referer $server_addr; | |
proxy_set_header Origin $server_addr; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Plex-Client-Identifier $http_x_plex_client_identifier; | |
proxy_set_header Cookie $http_cookie; | |
## Required for Websockets | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_read_timeout 36000s; # Timeout after 10 hours | |
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | |
proxy_pass http://plex-upstream; | |
} | |
} |
Worked for me on version 1.5.5.3634, thanks a lot!
Thanks a lot! 👍
I had this issue since a version where they blocked accessing Plex web GUI using FQDN other than the hostname... Had to use IP address since then... 😩
I confirm your gist is working with version 1.8.4.4249.
I can confirm this works with version 1.10.1.4602. I am using URL rewrite to permanently redirect HTTP to HTTPS like this: rewrite ^ https://$server_name$request_uri?$query_string permanent
. It works perfectly for me.
Plex version 1.13.5.5332-21ab172de and receiving the "Request came in with unrecognized domain / IP 'tv.example.com' in header Referer; treating as non-local" in logs. Been playing around with a lot of settings to no avail. Any ideas?
This works well for a server on the same network (after modifying the upstream server setting).
Thanks, works... tested on plexmediaserver 1.24.3.5033-757abe6b4
I get 502 bad gateway trying to use this. Redirect appears to be working but bad gateway.
plex server responds locally, tested with ssh tunnel.
@Bun-Bun please show your config
@afteroot which config are you looking for?
@afteroot which config are you looking for?
On which you get 502 error, maybe i can help you with config
I'm glad this is still proving helpful!
Working with Plex as of version 4.125.1
@afteroot which config are you looking for?
On which you get 502 error, maybe i can help you with config
I'm not sure which config you are referring. If you mean the nginx config it's the same config that is posted here. I drop it in place and got bad gateway.
@Bun-Bun , in that way you need to check that your upstream is correct
upstream plex-upstream {
server 127.0.0.1:32400;
}
Useful for latest version of Plex. Thanks!