Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running behind nginx-proxy #23

Open
chipsenkbeil opened this issue Mar 8, 2016 · 10 comments
Open

Running behind nginx-proxy #23

chipsenkbeil opened this issue Mar 8, 2016 · 10 comments

Comments

@chipsenkbeil
Copy link

Anyone have experience running Plex behind an nginx proxy: https://github.com/jwilder/nginx-proxy

I've got my site using SSL with the above proxy and companion container (https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion) to get SSL certificates from Let's Encrypt. I've had no luck getting plex to work behind it. With timhaak's version, I could specify a redirect port (80 goes to 32400) for Plex via PLEX_EXTERNALPORT and that sort of worked.

I could access my server directly, but not via plex.tv or my mobile app. Without running using net=host (which breaks the proxy setup), I haven't been able to get anything to work with this one when running behind the nginx proxy. Even with net=host, I had to use a relay option on plex.tv and my mobile app last night and it stopped working today. Not sure what the problem is there.

I've got 32400 forwarded. I did notice last night that a different port was made public when running as net=host than 32400, when looking at the server settings. Can't get back to that point now, though.

@chipsenkbeil
Copy link
Author

Here's an example of what I am seeing in the browser logs.

screen shot 2016-03-08 at 12 19 19 pm

@wernight
Copy link
Owner

wernight commented Mar 9, 2016

You may want to check https://support.plex.tv/hc/en-us/articles/201543147-What-network-ports-do-I-need-to-allow-through-my-firewall-

Also check your Preferences.xml and if you want to autologin without accessing using the web UI specify X_PLEX_TOKEN or PLEX_LOGIN and PLEX_PASSPORT, and possible PLEX_EXTERNAL_PORT (see README).

wernight added a commit that referenced this issue Mar 9, 2016
  - Renames and unify environment variables (fallback supported):
      PLEX_EXTERNALPORT -> PLEX_EXTERNAL_PORT
      PLEXPASS_LOGIN -> PLEX_LOGIN
      PLEX_USERNAME -> PLEX_LOGIN
      PLEXPASS_PASSWORD -> PLEX_PASSWORD
  - Supports X_PLEX_TOKEN during initial setup if provided (previously required
    PLEX_USERNAME and PLEX_PASSWORD).
  - Removes PLEX_LOGIN, PLEX_PASSWORD... from environment before
    running Plex.
  - Uses default Preferences.xml even if no username/password/token is
    provided so that for example PLEX_EXTERNAL_PORT can be used.
  - Document PLEX_EXTERNAL_PORT.

This should improve for issues #9 and issue #23.
@chipsenkbeil
Copy link
Author

Opened all ports, set my X_PLEX_TOKEN (had it earlier), and set the PLEX_EXTERNAL_PORT to 80 and 443 to see if either worked. Cannot get it to connect. Getting a lot of unreachable and preventing fallback of insecure connection. Trying to allow insecure connections didn't seem to do anything.

@wernight
Copy link
Owner

I suggest you check your network step by step. I don't know how many layers you have etc. I also don't know your docker-compose (if you're using that) or if you've setup linking correctly. I didn't use nginx-proxy image myself; usually I do that myself.

Now from the log is says ERR_INSECURE_RESPONSE which is normal because its a self signed certificate. Given its in your browser, you may want to add nginx-proxy self-signed certificate if it generates any, to your browser. You can also type badidea if you're using Chrome.

@chipsenkbeil
Copy link
Author

I don't think nginx-proxy is using self-signed certificates. I give it a directory to look for certificates to use when serving subdomains and I have a companion container that reaches out to Let's Encrypt for subdomain certificates and places them in that directory.

Of course, I don't know nginx that well, so maybe there are other certificates you are referring to? Couldn't seem to figure out how to use badidea (or the former danger). Was trying in the console. Not sure if there was somewhere else to use it. I'll double-check that the ports I specified are open and reachable later this week.

Thanks for all of the help so far!

@wernight
Copy link
Owner

Just type it in the page, even if nothing is visible. But understand the meaning: It'll just allow man-in-middle attacks so it's pretty much the same as if you had plain HTTP without TSL.

@chipsenkbeil
Copy link
Author

So, tried typing 'badidea' and 'danger' into Chrome. Can't tell if it did anything and the only thing I can find online is that it should apply if the window is in focus.

Anyway, I selected the "use fallback" option as well, but it does seem to have helped with issues of cross-origin headers, the insecure response, and other errors.

screen shot 2016-03-21 at 11 25 43 am

Looks like it tries a mix of 172.17.0.9, the Docker container's IP, and my server's IP in the requests.

[EDIT]
I even ran it with --net=host without success. I used my domain name (using no-ip.org for dynamic IP support) and my server's current IP and couldn't get it to work.

Same issues regarding insecure response (badidea does nothing) and preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://app.plex.tv' is therefore not allowed access. The response had HTTP status code 404.

@wernight
Copy link
Owner

May I ask why you're using nginx reverse proxy? Plex doesn't need to run behind Nginx.

@chipsenkbeil
Copy link
Author

I'm using the Docker nginx-proxy project because it allows me to assign containers to different subdomains on my main domain. So, I can visit https://plex.example.com to reach my plex server.

I've got other containers like the Docker UI project running and accessible via https://ui.example.com, Gitlab via https://git.example.com, etc.

So, it's just a really handy setup for me to run different services all tied to the same address and port from the perspective of the user.

As a side note, I switched back to timhaak/plex and it works fine going directly to it (https://plex.example.com) and offers indirect streaming on my phone, just like before (does't work through plex.tv). So, not sure what is different. :/

@wernight
Copy link
Owner

I get that, but you can access via plex.tv and you don't need an accessible subdomain. You can use also another port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants