AlphaOmega2020

plex.subdomain.conf

Dec 2nd, 2025
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. ## Version 2025/07/18
  2. # make sure that your plex container is named plex
  3. # make sure that your dns has a cname set for plex
  4. # if plex is running in bridge mode and the container is named "plex", the below config should work as is
  5. # if not, replace the line "set $upstream_app plex;" with "set $upstream_app <containername>;"
  6. # or "set $upstream_app <HOSTIP>;" for host mode, HOSTIP being the IP address of plex
  7. # in plex server settings, under network, fill in "Custom server access URLs" with your domain (ie. "https://plex.yourdomain.url:443")
  8.  
  9. server {
  10. listen 443 ssl;
  11. # listen 443 quic;
  12. listen [::]:443 ssl;
  13. # listen [::]:443 quic;
  14.  
  15. server_name plex.*;
  16.  
  17. include /config/nginx/ssl.conf;
  18.  
  19. client_max_body_size 0;
  20. proxy_redirect off;
  21. proxy_buffering off;
  22.  
  23. # enable for ldap auth (requires ldap-location.conf in the location block)
  24. #include /config/nginx/ldap-server.conf;
  25.  
  26. # enable for Authelia (requires authelia-location.conf in the location block)
  27. #include /config/nginx/authelia-server.conf;
  28.  
  29. # enable for Authentik (requires authentik-location.conf in the location block)
  30. #include /config/nginx/authentik-server.conf;
  31.  
  32. # enable for Tinyauth (requires tinyauth-location.conf in the location block)
  33. #include /config/nginx/tinyauth-server.conf;
  34.  
  35. location / {
  36. # enable the next two lines for http auth
  37. #auth_basic "Restricted";
  38. #auth_basic_user_file /config/nginx/.htpasswd;
  39.  
  40. # enable for ldap auth (requires ldap-server.conf in the server block)
  41. #include /config/nginx/ldap-location.conf;
  42.  
  43. # enable for Authelia (requires authelia-server.conf in the server block)
  44. #include /config/nginx/authelia-location.conf;
  45.  
  46. # enable for Authentik (requires authentik-server.conf in the server block)
  47. #include /config/nginx/authentik-location.conf;
  48.  
  49. # enable for Tinyauth (requires tinyauth-server.conf in the server block)
  50. #include /config/nginx/tinyauth-location.conf;
  51.  
  52. include /config/nginx/proxy.conf;
  53. include /config/nginx/resolver.conf;
  54. set $upstream_app plex;
  55. set $upstream_port 32400;
  56. set $upstream_proto http;
  57. proxy_pass $upstream_proto://$upstream_app:$upstream_port;
  58.  
  59. proxy_set_header X-Plex-Client-Identifier $http_x_plex_client_identifier;
  60. proxy_set_header X-Plex-Device $http_x_plex_device;
  61. proxy_set_header X-Plex-Device-Name $http_x_plex_device_name;
  62. proxy_set_header X-Plex-Platform $http_x_plex_platform;
  63. proxy_set_header X-Plex-Platform-Version $http_x_plex_platform_version;
  64. proxy_set_header X-Plex-Product $http_x_plex_product;
  65. proxy_set_header X-Plex-Token $http_x_plex_token;
  66. proxy_set_header X-Plex-Version $http_x_plex_version;
  67. proxy_set_header X-Plex-Nocache $http_x_plex_nocache;
  68. proxy_set_header X-Plex-Provides $http_x_plex_provides;
  69. proxy_set_header X-Plex-Device-Vendor $http_x_plex_device_vendor;
  70. proxy_set_header X-Plex-Model $http_x_plex_model;
  71.  
  72. #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)
  73. gzip on;
  74. gzip_vary on;
  75. gzip_min_length 1000;
  76. gzip_proxied any;
  77. gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml;
  78. gzip_disable "MSIE [1-6]\.";
  79.  
  80. #Nginx default client_max_body_size is 1MB, which breaks Camera Upload feature from the phones.
  81. #Increasing the limit fixes the issue. Anyhow, if 4K videos are expected to be uploaded, the size might need to be increased even more
  82. client_max_body_size 100M;
  83.  
  84. #Forward real ip and host to Plex
  85. proxy_set_header Host $host;
  86. proxy_set_header X-Real-IP $remote_addr;
  87. #When using ngx_http_realip_module change $proxy_add_x_forwarded_for to '$http_x_forwarded_for,$realip_remote_addr'
  88. proxy_set_header X-Forwarded-For $http_x_forwarded_for,$realip_remote_addr;
  89. proxy_set_header X-Forwarded-Proto $scheme;
  90. proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
  91. proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
  92. proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
  93.  
  94. #Websockets
  95. proxy_set_header Upgrade $http_upgrade;
  96. proxy_set_header Connection "Upgrade";
  97.  
  98. #Disables compression between Plex and Nginx, required if using sub_filter below.
  99. #May also improve loading time by a very marginal amount, as nginx will compress anyway.
  100. #proxy_set_header Accept-Encoding "";
  101.  
  102. #Buffering off send to the client as soon as the data is received from Plex.
  103. proxy_buffering off;
  104.  
  105. }
  106.  
  107. location /library/streams/ {
  108. set $upstream_app plexpms;
  109. set $upstream_port 32400;
  110. set $upstream_proto http;
  111. proxy_pass $upstream_proto://$upstream_app:$upstream_port;
  112. proxy_pass_request_headers off;
  113. }
  114. }
  115.  
Advertisement
Add Comment
Please, Sign In to add comment