Plex Media Server web proxy fix

Note: this post was migrated from my old Tumblr-backed blog

A recent update to Plex Media Server broke the proxy I had set up for the web dashboard, and after about a week or so of pulling my hair out, I discovered a fix.

A little background: I have a server that proxies requests to all of my services that run on their own ports so I don’t need to remember which ports things are running on. This allows me to go to ‘http://sickbeard.example.com’ rather than ‘http://myserver.example.com:8081’ and this is the same for sabnzbd, couchpotato and even Plex. This proxying is done with virtualhosts configured in nginx, and for Plex, I had a convenience redirect to bring me to the main dashboard when going to the main page (rather than having to go to ‘/web/index.html’ manually every time).

Anyway, it turns out that the issue was that the Javascript in the dashboard that populates the screen with your recently watched stuff and your media types was attempting to retrieve metadata about Plex by hitting ‘/’, but that was triggering my redirect to ‘/web/index.html’ rather than allowing the dashboard to get its data. This caused an error which manifested itself as a “This media server is unavailable to you” screen.

The fix I put in place is to check for the existence of the X-Plex-Device-Name HTTP header on requests to /, and if they exist, then don’t redirect, otherwise, redirect as normal.

A gist of an example nginx config follows:

I’ve been staring at a lot of Wireshark output for the last few hours, so if this doesn’t make any sense or you have any questions, let me know and I’ll try to help you out.

TL;DR: if you are running an nginx proxy for Plex and it broke in the last week or so, I found a fix. see link to gist for nginx config.