Last active
August 26, 2024 15:22
-
-
Save ometa/654376bf0e12e6131f2b809b3dc0f151 to your computer and use it in GitHub Desktop.
NGINX reverse proxy in front of Plex media server v1.3.3.3148
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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; | |
} | |
} |
@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;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.