diff --git a/docs/applications/plex.mdx b/docs/applications/plex.mdx index 4a218a859..cf8b77792 100644 --- a/docs/applications/plex.mdx +++ b/docs/applications/plex.mdx @@ -114,3 +114,121 @@ If you need to link your Plex instance to another application, such as Sonarr or Host: 127.0.0.1 Port: ``` +## Plex Nginx Configuration (optional) + +### Subdomain + +This method serves Plex on it's own domain. This can be a subdomain you've registered through [LetsEncrypt](https://swizzin.ltd/applications/letsencrypt), answering "no" to applying the config to the swizzin default. +After this, you can use the nginx configuration below with some minor modifications in order to get Plex up and serving on your own (sub)domain. +The following can either be appended to ``/etc/nginx/sites-enabled/default`` or can (better method) be put into it's own file at ``/etc/nginx/sites-enabled/plex.conf``. +Prior to installing this configuration, navagate to [app.plex.tv](https://app.plex.tv) and use the settings listed in the box below. +After making changes, ``sudo nginx -t`` to test your config, then ``sudo nginx -s reload`` to apply it. +You can also apply ``allowLocalhostOnly="1"`` to your Plex ``Preferences.xml`` file to force it to stop serving on the port. + +
Subdomain Configuration (Nginx) +```plaintext main +set ``Remote Access - Disable``, +Network -> Custom server access URLs = https://:443,http://:80 +Network -> Secure connections = Preferred. +``` + +```nginx +upstream plex_backend { + server 127.0.0.1:32400; + keepalive 32; +} + +map $http_upgrade $connection_upgrade { + default upgrade; + '' close; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + # Define Server Domain + server_name plex.yourdomain.com; + + ssl_certificate /etc/nginx/ssl/plex.yourdomain.com/fullchain.pem; + ssl_certificate_key /etc/nginx/ssl/plex.yourdomain.com/key.pem; + + include snippets/ssl-params.conf; + # + send_timeout 100m; + # + location / { + # Sockets + 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; + # Plex Headers + 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; + # Allows All Encodings + proxy_set_header Accept-Encoding ""; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_ssl_verify off; + proxy_http_version 1.1; + proxy_set_header Host $http_host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_read_timeout 86400; + proxy_pass https://plex_backend; + } +} +``` +
+ +### App Location + +One option of getting Plex to serve on your domain correctly is to ``nano /etc/nginx/apps/plex.conf`` and paste the following. +This is far from an ideal solution, but is one surefire way of getting the mediaserver to serve on the correct port and location. +For this method, please apply the following settings to plex. After making changes, ``sudo nginx -t`` to test your config, then ``sudo nginx -s reload`` to apply it. + +
+ Location Configuration (Nginx) + +```plaintext main +set ``Remote Access - Disable``, +Network - Custom server access URLs = https://:443/web,http://:80/web +Network - Secure connections = Preferred. +``` + +```nginx +location /web { + #Example of using sub_filter to alter what Plex displays, this disables Plex News. + #sub_filter ',news,' ','; + # Pass Plex + proxy_pass http://127.0.0.1:32400/web; + 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 $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + # Allow HTTP Upgrades + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_redirect off; + proxy_buffering off; +} +``` +
+ + +## Tunnelling Plex to VPS + +[See this Gist](https://gist.github.com/MarMed/94b5537a9fb61cf7212808692bbef14d) + + +