upstream plex-upstream { | |
# change plex-server.example.com:32400 to the hostname:port of your plex server. | |
# this can be "localhost:32400", for instance, if Plex is running on the same server as nginx. | |
server plex-server.example.com:32400; | |
} | |
server { | |
listen 80; | |
# server names for this server. | |
# any requests that come in that match any these names will use the proxy. | |
server_name | |
tv | |
plex | |
tv.example.com | |
plex.example.com; | |
# this is where everything cool happens (you probably don't need to change anything here): | |
location / { | |
# if a request to / comes in, 301 redirect to the main plex page. | |
# but only if it doesn't contain the X-Plex-Device-Name header | |
# this fixes a bug where you get permission issues when accessing the web dashboard | |
if ($http_x_plex_device_name = '') { | |
rewrite ^/$ http://$http_host/web/index.html; | |
} | |
# set some headers and proxy stuff. | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_redirect off; | |
# include Host header | |
proxy_set_header Host $http_host; | |
# proxy request to plex server | |
proxy_pass http://plex-upstream; | |
} | |
} |
This comment has been minimized.
This comment has been minimized.
Is there any way to get auth_basic working for this? I've tried enabling just under 'location / {' and now it's throwing me into a redirect loop asking me for a password over and over :( |
This comment has been minimized.
This comment has been minimized.
Anyone ever tried to mount plex in a folder? |
This comment has been minimized.
This comment has been minimized.
@cbetta what do you mean, exactly? |
This comment has been minimized.
This comment has been minimized.
i think cbetta want to access plex at hisdomain.tld/plex/ by puting the proxy_pass inside a 'location /plex/' |
This comment has been minimized.
This comment has been minimized.
@Quark-X10 ahhh, I see. yeah, so that would not work because
note: this is untested, so it may not work. but try it out. (based on example at: http://wiki.nginx.org/HttpProxyModule#proxy_pass) |
This comment has been minimized.
This comment has been minimized.
For anyone looking to do authentication, here's how I have it setup in mine. This will allow a connection from 10.10.10.1 and from 192.168.1.1-192.168.1.255 without authentication. If you are coming from outside those IP addresses, you will be prompted for a username and password. If you don't want the ip address bypass, just leave those lines out.
|
This comment has been minimized.
This comment has been minimized.
I've found a clean solution to authenticate plex on the localhost - run either plex, or nginx, inside of a docker container. If you're unfamiliar with Docker, the "easy" choice is to run nginx, here's the quick version if you are only using nginx for plex:
== Long version == Plex is incapable of authenticating 127.0.0.1 because their architecture requires this to be open. All current solutions I've seen enable HTTP basic authentication. This is imperfect, because
Basically, if you use docker to "contain" either nginx or plex, you get an isolated system (docker basically gives you a really tiny virtual machine - like less than 5MB tiny). This means that plex and nginx will have different IP addresses. So you can still use your proxy, but you can toss out HTTP authentication and use myplex authentication instead, which integrates properly with plex. |
This comment has been minimized.
This comment has been minimized.
BTW, the error log reports a lot of these (and there are lots of notifications of connection lost from the webUI):
which I seem to be able to stop by adding a few websocket items to the proxy:
I'm no wiz with websockets or nginx - perhaps someone can help ID if this is indeed a fix, and if so can perhaps modify the config so that a connection is only upgraded for the /websockets URL - I think these lines try to upgrade every http connection |
This comment has been minimized.
This comment has been minimized.
thanks @hamiltont! unfortunately, I'm currently running plex in OSX, so Docker isn't an option, but I think I might move to that when I build my new mediaserver (I've already been running minecraft server in a docker container to learn it). The current setup is running Plex on OSX and nginx is doing all the proxying through one of my linux servers. I'll get the websocket upgrade stuff in my config set up and make sure everything is working right. |
This comment has been minimized.
This comment has been minimized.
Thought I should share since this config helped me get going when I first started. The recent plexweb 2.0 upgrade broke my config because of the way nginx does urlencode. Maybe my config broke because I am proxying multiple things; not sure. If your setup was affected, you can see how I got around it here: https://forums.plex.tv/index.php/topic/108354-trouble-recently-proxying-web-interface/ |
This comment has been minimized.
This comment has been minimized.
Woops...posted that in a plexpass only forum. Here is a better link. Cheers! https://forums.plex.tv/index.php/topic/108070-cannot-play-media-from-wan/page-2?p=654460 |
This comment has been minimized.
This comment has been minimized.
This works great so far! However, when I access my plex server from the LAN it requires me to login to an account rather than the typical LAN behavior of letting you go right in. I tried playing around and fixing it but was not successful. Anyway to make this happen? |
This comment has been minimized.
This comment has been minimized.
I think there was an update in plex recently which broke this for auto login. The below is the configuration I use that is working great for me. The geo stuff allows me to say which IP address ranges are allowed "unrestricted" access, as I have plex configured to Require authentication on local networks. This means only 127.0.0.1 gets full access, but my local lan address of my plex box, needs to login. This means plex must be running on the same machine as nginx.
|
This comment has been minimized.
This comment has been minimized.
Quick question is it possible to do the following: |
This comment has been minimized.
This comment has been minimized.
Does somebody has the right configuration for Plex with HTTPS ? |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
I'm very new to nginx and I've tried using this gist but to redirect traffic to plex when fetching from domain.tld/location instead of just domain.tld. E.g.: my.server.com/plex. I've tried the rewrite rule mentioned earlier but without success. Anyone has got this going, and if so, care to share the solution? |
This comment has been minimized.
This comment has been minimized.
If somebody wants to get |
This comment has been minimized.
This comment has been minimized.
I tried your conf file and it works great, however when I load my dashboard it can't reach my server. Could the NAT be causing the issue? Am currently Mapping a public IP to a private IP(Proxy) which then sends the request to the actual Plex server. Any help would be greatly appreciated. |
This comment has been minimized.
This comment has been minimized.
Awesome <3 |
This comment has been minimized.
This comment has been minimized.
Hey, thanks so much for this it really helped a lot! I had to modify it a little bit to get Plex working properly on my server so I'm dropping some information here in case anybody else runs into my problem. OS: CentOS 7 Whenever I opened Plex in my browser and started clicking around I kept getting kicked back to the login screen and a notification would show saying
This happened very frequently and would even interrupt shows I was watching and kick me back to the login page. I checked the activity log and saw multiple instances of the same message.
I looked in the nginx error log file (/var/log/nginx/error.log) and I found these error messages
After searching around for a long time with no results I noticed the config file posted by @techmunk and decided to take some pieces of it to see if they helped. The following is the resulting config file which solved my problem.
I no longer have any problems and the activity log shows the proper message
Hopefully this helps someone else who is having the same issue I was. |
This comment has been minimized.
This comment has been minimized.
Getting errors trying to set this up in my existing nginx proxy... Creating a new CONF for plex = http://pastebin.com/HUb8byv1 Please note using an IP address or resolved name makes no difference... Any ideas? |
This comment has been minimized.
This comment has been minimized.
@james-d-hasselman solution worked for me with plex-pass version 0.9.15.1. |
This comment has been minimized.
This comment has been minimized.
With redirecting to /web/index.html as above I had a problem connecting via the Plex.tv web app (with custom server access URL defined). I got a If this happens to you, only redirect with its not an OPTIONS requests as below.
|
This comment has been minimized.
This comment has been minimized.
I had to add this for playing to work:
|
This comment has been minimized.
This comment has been minimized.
Wow this drove me absolutely nuts, thank you so much @thomasjwebb |
This comment has been minimized.
This comment has been minimized.
Used @james-d-hasselman's code plus @thomasjwebb's header. worked perfectly. thanks guys |
This comment has been minimized.
This comment has been minimized.
I've managed to get the streaming working over the web in browser with the header from @thomasjwebb, but my Android clients fail to stream, the message recommends to restart the client and server. iOS works fine. Any suggestions? |
This comment has been minimized.
This comment has been minimized.
I'm not sure what I'm doing wrong, this code doesn't seem to work. I tried Subtletree's combo of hasselman and thomaswebb's code and was met with this message: nginx: [emerg] "upstream" directive is not allowed here in /usr/local/etc/nginxnginx.conf:1 I even went as far as copying the code directly from the zip and unzipping the file directly in it's place and get the same error message? I'm using nginx-1.8.1_2,2. I don't know a terrible amount about reverse proxies except that I set up the first one for the majority of the services running in my Freenas box, and I wanted to get this to work for Plex to make it easier to access from everywhere. I will continue to read the documentation about nginx to see if I have something wrong or what have you until I see someone respond. Do I need to install additional packages to get this to work? Thank you for any insight into the matter! update... got this to work. Problem was missing a lot of necessary code I think... I had to add some of the basic data like worker_processes 1; and some other code; is that code truly necessary for this to work? updated code below:
|
This comment has been minimized.
This comment has been minimized.
I had to add a few things to get this all working:
The /web redirect was also a problem with the Fire TV, it doesn't send headers, it uses query strings so I had to make some tweaks there too otherwise the Fire TV would say that it couldn't connect.
Hopefully that helps someone. |
This comment has been minimized.
This comment has been minimized.
Doonga - helped me, thanks! |
This comment has been minimized.
This comment has been minimized.
I used Doonga's Headers but I'm not sure if it mattered. I used the orginal config in this gist but had to change proxy_pass http://plex-upstream; to proxy_pass http://plex-upstream/; Notice the trailing / at the end? That made it work for me. Now when ever any one visits my URL they get plex and do not have to enter the port or the url. |
This comment has been minimized.
This comment has been minimized.
This configuration forces me to log into Plex account from LAN. So I can reach the Web GUI only from localhost. I'm running Plex Server 1.1.4.2757. |
This comment has been minimized.
This comment has been minimized.
Had some problems setting this up for plex, couchpotato, sabnzbd etc. Problems seem to have been fixed by changing:
to:
|
This comment has been minimized.
This comment has been minimized.
Hey all, After a few hours of hacking and testing, I was able to get Plex Media Server v1.3.3.3148 working behind an NGINX reverse proxy on my local LAN, without it prompting for any authentication. Here is my gist with the configuration. The key was the following configuration, which forces plex to see the request as coming from an IP in the whitelisted network:
Hope this helps others! Devin |
This comment has been minimized.
This comment has been minimized.
Having some problems with downloading (not streaming) movies from Plex, using this Nginx configuration. Edit: This is a Plex bug, I think. https://forums.plex.tv/discussion/256039/download-stopping-at-exactly-1024mb#latest |
This comment has been minimized.
This comment has been minimized.
So I am having this same problem on latest version of plex and version 1.10.2 of nginx. Here is my code: `upstream plex-upstream { server {
} Getting this in my logs: 2017/03/15 19:37:37 [error] 65282#100149: *1 open() "/usr/local/www/nginx/plex" failed (2: No such file or directory), client: 10.150.1.192, server: localhost, request: "GET /plex HTTP/1.1", host: "nginxtest.me.local" |
This comment has been minimized.
This comment has been minimized.
thanks |
This comment has been minimized.
This comment has been minimized.
Did you ever get it working @andrewm659 ? |
This comment has been minimized.
Thank you so much for this! I had a different issue than you, but your config helped me figure it out. I had been trying to get this to work for a few days prior.