Skip to main content PleX update broke my reverse proxy configuration : r/PleX
Go to PleX

PleX update broke my reverse proxy configuration

Help

Hello!
I have a PleX server on my home pc and I have a vpn to my home to access it trough private ip.
As I have a lot of services running, I installed Nginx, created a url for it, and started mapping.

The problem is:
All of my urls are under one single domain name, i.e., i access media.mydomain.com, it gives me a home page for my internal links, and when i click one, it redirects to media.mydomain.com/plex, and after the last update, plex isn't working anymore! It gives me all white screen, no errors on error.log or access.log on nginx side.
The only error i found is in console from the browser, it gives me this:

r/PleX - plex error browser
plex error browser

This error does not occur when I access through media.mydomain.com:32400 or locally with 127.0.0.1:32400

This is the current plex configuration. If someone has a light on what could possibly be wrong. I already tried to move the files to another folder and ask plex to repair it self, but that did not work.

I have to access through a single link (can't add a plex.mydomain.com)

And pardon for my bad english

location /plex {
            rewrite /plex(/.*) $1 break;
            proxy_pass http://localhost:32400;
            proxy_http_version 1.1;
            proxy_set_header Accept-Encoding "";
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $http_host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;

            sub_filter '/web/' '/plex/web/';
            sub_filter_types *;
            sub_filter_once off;

        }

UPDATE 1:

After some research, I found the issue! The issue was nginx altering js and css files with the sub_filter directive, and it was raising a flag for SRI (Subresource Integrity). The solution was to sub_filter only html files, not js and css. To do that, i alter thje sub_filter_types *; to sub_filter_types html;

The final configuration is this:

        location /plex/ {
            rewrite /plex(/.*) $1 break;
            proxy_pass http://localhost:32400/web/;
            proxy_http_version 1.1;
            proxy_set_header Accept-Encoding "";
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $http_host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_redirect off;
            sub_filter '/web/' '/plex/web/';
            sub_filter_types html;
            sub_filter_once off;
        }

Hope that helps anyone out there!

Unfortunately, no luck at all :(
I tried that config on my side, but it didn't work either! I didn't get the web sockets to work properly, maybe because I'm running nginx directly onto Windows, but I'll try again when I get more time.

Hopefully I'll find a way, until then, I'm accessing with URL + port.

If I have time I'll see if I can see the generated file from npm for Plex. Mine has been working so far...

Kinda late but here is my whole config from npm. Replace all things with << >>. I use a wildcard ssl for this domain

map $scheme $hsts_header {
    https   "max-age=63072000; preload";
}

server {
  set $forward_scheme http;
  set $server         "<<IP OR HOSTNAME>>";
  set $port           32400;

  listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;

  server_name << WEBSITE URL >>;
  # Let's Encrypt SSL
  include conf.d/include/letsencrypt-acme-challenge.conf;
  include conf.d/include/ssl-ciphers.conf;
  ssl_certificate /etc/letsencrypt/live/npm-12/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/npm-12/privkey.pem;

# Asset Caching
  include conf.d/include/assets.conf;

  # Block Exploits
  include conf.d/include/block-exploits.conf;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;


  access_log /data/logs/proxy-host-13_access.log proxy;
  error_log /data/logs/proxy-host-13_error.log warn;

  location / {
    location / {
            proxy_pass  << INTERNAL URL >>;

            proxy_set_header        referer                 "";
            proxy_set_header        origin                 "";

            # Enable websockets
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_cache_bypass $http_upgrade;
    }

    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_pass       << INTERNAL URL>>;

    # Asset Caching
  include conf.d/include/assets.conf;


  # Block Exploits
  include conf.d/include/block-exploits.conf;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;

  }

  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}

Tried with your configs but still no luck, i'm almost giving up on this! Posted on forum plex but no one replied yet

Update: I have just found the solution! The problem is that sub_filter was messing with the delivery of Java Script and CSS files, and it was making the browser to suspect and blocking these. I've update the nginx file, on the section             sub_filter_types *; to filter only text/html files.

so thje configs looks like this now:

        location /plex/ {
            rewrite /plex(/.*) $1 break;
            proxy_pass http://localhost:32400/web/;
            proxy_http_version 1.1;
            proxy_set_header Accept-Encoding "";
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $http_host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_redirect off;
            sub_filter '/web/' '/plex/web/';
            sub_filter_types html;
            sub_filter_once off;
        }
More replies
More replies
More replies