Repository navigation
Expand file tree
/
Copy pathplex-live-tv-elevate.nginx.conf.example
More file actions
68 lines (58 loc) · 2.72 KB
/
Copy pathplex-live-tv-elevate.nginx.conf.example
File metadata and controls
68 lines (58 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Example manual Plex Live TV entitlement proxy using nginx + njs.
#
# This is for operators who want the same owner-token elevation pattern without
# running `iptv-tunerr plex-label-proxy`. It intentionally mirrors Tunerr's
# hardened allowlist:
# - only GET/HEAD/OPTIONS are eligible
# - explicit Live TV/provider paths are eligible
# - transcode/playQueue helper requests are eligible only when path/uri points
# at a Live TV session/provider
# - arbitrary bait query params do not elevate
#
# Requirements:
# - nginx built with ngx_http_js_module
# - ngx_http_sub_module for the optional allowTuners response rewrite
# - njs script from docs/examples/plex-live-tv-elevate.njs copied to:
# /etc/nginx/plex-live-tv-elevate.njs
# - PLEX_OWNER_TOKEN exported to nginx workers through the `env` directive
#
# Keep this frontend private or behind TLS/VPN/Cloudflare Tunnel. Proxied users
# do not receive the raw owner token, but this proxy is still a limited
# owner-token deputy for allowlisted Live TV reads.
load_module modules/ngx_http_js_module.so;
env PLEX_OWNER_TOKEN;
http {
js_import plex from /etc/nginx/plex-live-tv-elevate.njs;
js_set $plex_effective_args plex.effectiveArgs;
js_set $plex_effective_token plex.effectiveToken;
upstream plex_origin {
server 127.0.0.1:32400;
}
server {
listen 443 ssl http2;
server_name media.example.com;
ssl_certificate /etc/nginx/tls/media.example.com.crt;
ssl_certificate_key /etc/nginx/tls/media.example.com.key;
location / {
proxy_http_version 1.1;
proxy_set_header Host 127.0.0.1:32400;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection "";
# PMS accepts X-Plex-Token in either query string or header. The
# njs helper replaces the query token on elevated requests and this
# header keeps PMS behavior consistent for clients that supplied the
# token only as a header.
proxy_set_header X-Plex-Token $plex_effective_token;
# Disable upstream compression so sub_filter can rewrite the small
# XML allowTuners hints that Plex Web uses to reveal Live TV UI.
proxy_set_header Accept-Encoding "";
sub_filter_types application/xml text/xml text/plain;
sub_filter_once off;
sub_filter 'allowTuners="0"' 'allowTuners="1"';
sub_filter '<Setting id="allowTuners" value="0"' '<Setting id="allowTuners" value="1"';
proxy_pass http://plex_origin$uri?$plex_effective_args;
}
}
}