Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Version 2025/07/18
- # make sure that your plex container is named plex
- # make sure that your dns has a cname set for plex
- # if plex is running in bridge mode and the container is named "plex", the below config should work as is
- # if not, replace the line "set $upstream_app plex;" with "set $upstream_app <containername>;"
- # or "set $upstream_app <HOSTIP>;" for host mode, HOSTIP being the IP address of plex
- # in plex server settings, under network, fill in "Custom server access URLs" with your domain (ie. "https://plex.yourdomain.url:443")
- server {
- listen 443 ssl;
- # listen 443 quic;
- listen [::]:443 ssl;
- # listen [::]:443 quic;
- server_name plex.*;
- include /config/nginx/ssl.conf;
- client_max_body_size 0;
- proxy_redirect off;
- proxy_buffering off;
- # enable for ldap auth (requires ldap-location.conf in the location block)
- #include /config/nginx/ldap-server.conf;
- # enable for Authelia (requires authelia-location.conf in the location block)
- #include /config/nginx/authelia-server.conf;
- # enable for Authentik (requires authentik-location.conf in the location block)
- #include /config/nginx/authentik-server.conf;
- # enable for Tinyauth (requires tinyauth-location.conf in the location block)
- #include /config/nginx/tinyauth-server.conf;
- location / {
- # enable the next two lines for http auth
- #auth_basic "Restricted";
- #auth_basic_user_file /config/nginx/.htpasswd;
- # enable for ldap auth (requires ldap-server.conf in the server block)
- #include /config/nginx/ldap-location.conf;
- # enable for Authelia (requires authelia-server.conf in the server block)
- #include /config/nginx/authelia-location.conf;
- # enable for Authentik (requires authentik-server.conf in the server block)
- #include /config/nginx/authentik-location.conf;
- # enable for Tinyauth (requires tinyauth-server.conf in the server block)
- #include /config/nginx/tinyauth-location.conf;
- include /config/nginx/proxy.conf;
- include /config/nginx/resolver.conf;
- set $upstream_app plex;
- set $upstream_port 32400;
- set $upstream_proto http;
- proxy_pass $upstream_proto://$upstream_app:$upstream_port;
- proxy_set_header X-Plex-Client-Identifier $http_x_plex_client_identifier;
- proxy_set_header X-Plex-Device $http_x_plex_device;
- proxy_set_header X-Plex-Device-Name $http_x_plex_device_name;
- proxy_set_header X-Plex-Platform $http_x_plex_platform;
- proxy_set_header X-Plex-Platform-Version $http_x_plex_platform_version;
- proxy_set_header X-Plex-Product $http_x_plex_product;
- proxy_set_header X-Plex-Token $http_x_plex_token;
- proxy_set_header X-Plex-Version $http_x_plex_version;
- proxy_set_header X-Plex-Nocache $http_x_plex_nocache;
- proxy_set_header X-Plex-Provides $http_x_plex_provides;
- proxy_set_header X-Plex-Device-Vendor $http_x_plex_device_vendor;
- proxy_set_header X-Plex-Model $http_x_plex_model;
- #Plex has A LOT of javascript, xml and html. This helps a lot, but if it causes playback issues with devices turn it off. (Haven't encountered any yet)
- gzip on;
- gzip_vary on;
- gzip_min_length 1000;
- gzip_proxied any;
- gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml;
- gzip_disable "MSIE [1-6]\.";
- #Nginx default client_max_body_size is 1MB, which breaks Camera Upload feature from the phones.
- #Increasing the limit fixes the issue. Anyhow, if 4K videos are expected to be uploaded, the size might need to be increased even more
- client_max_body_size 100M;
- #Forward real ip and host to Plex
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- #When using ngx_http_realip_module change $proxy_add_x_forwarded_for to '$http_x_forwarded_for,$realip_remote_addr'
- proxy_set_header X-Forwarded-For $http_x_forwarded_for,$realip_remote_addr;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
- proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
- proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
- #Websockets
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "Upgrade";
- #Disables compression between Plex and Nginx, required if using sub_filter below.
- #May also improve loading time by a very marginal amount, as nginx will compress anyway.
- #proxy_set_header Accept-Encoding "";
- #Buffering off send to the client as soon as the data is received from Plex.
- proxy_buffering off;
- }
- location /library/streams/ {
- set $upstream_app plexpms;
- set $upstream_port 32400;
- set $upstream_proto http;
- proxy_pass $upstream_proto://$upstream_app:$upstream_port;
- proxy_pass_request_headers off;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment