Configure a Plex Media Server reverse proxy with nginx on Linux for convenient remote access. The best way to use a reverse proxy for people with dynamic IP addresses is to use a free dynamic DNS service like AfraidDNS (guide for automating), DuckDNS or No-IP. When you are done with this Plex reverse proxy tutorial you will be able to access Plex without plex.tv and instead use your custom DNS address like http://htpcguides.crabdance.com/web instead of http://IP:32400/web. This Plex reverse proxy how-to was tested on Debian and Ubuntu but the nginx virtual host should work on any Linux system. I also managed to get a custom location to work so you can use /plex instead of /web.
Configure Plex Media Server Reverse Proxy nginx Linux
I will assume you already have a dynamic DNS address configured. For the best results use your router running dd-wrt or OpenWRT to update your free dynamic DNS. At the very least do not use a device that is connected to a VPN service like PIA, PureVPN or IPVanish etc. Something like a Raspberry Pi would be a good choice since it uses very little power and physical space.
Pi Unit | ||||||||
---|---|---|---|---|---|---|---|---|
Raspberry Pi 3 | Quad Core | |||||||
Raspberry Pi 2 | Quad Core | |||||||
Raspberry Pi | Single Core | |||||||
Banana Pi | Dual Core | |||||||
Banana Pi Pro | Dual Core |
Configure Plex with Dynamic DNS
If you are behind a VPN this can allow you to still access Plex by your dynamic DNS address without having to resort to iptable rules.
Note that if you use plex.tv for gaining access to other Plex servers this will not fix that. You will have to have your friends use a similar set up and connect to them directly.
In the Plex Media Server settings click Server at the top and click Network in the sidebar
Click SHOW ADVANCED at the top
For Custom server access URLs enter your dynamic DNS address
Scroll down and click Save Changes
Configure Plex Reverse Proxy with nginx
Install nginx on Debian or Ubuntu
sudo apt-get update
sudo apt-get install nginx -y
Unlink the default nginx host
sudo unlink /etc/nginx/sites-enabled/default
Create the Plex nginx reverse proxy virtual host
sudo nano /etc/nginx/sites-available/reverse
Paste this working Plex reverse proxy nginx virtual host.
Change to match your dynamic DNS address (here htpcguides.crabdance.com
) and local IP address (here 192.168.40.105
).
If you already have a reverse proxy set up then only add the blue block.
server {
listen 80;
server_name htpcguides.crabdance.com 192.168.40.105;
location /web {
proxy_pass http://127.0.0.1:32400;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
To use a custom location like /plex for your nginx reverse proxy, you can try the virtualhost below. It requires the one above as well. I tested this and it worked, credit goes to information found here and more information from here and here.
Only add the blue section if you already have a reverse proxy nginx virtual host.
server {
listen 80;
server_name htpcguides.crabdance.com 192.168.40.105;
location /web {
proxy_pass http://127.0.0.1:32400;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /plex {
proxy_pass http://127.0.0.1/web;
}
}
Link your Plex nginx virtual host into sites-enabled
sudo ln -s /etc/nginx/sites-available/reverse /etc/nginx/sites-enabled/reverse
Test nginx to make sure your configuration has the correct syntax
sudo nginx -t
If you got no errors then restart nginx to activate the Plex reverse proxy
sudo service nginx restart
Now you can access Plex via reverse proxy using your dynamic DNS address and bypass plex.tv, make sure to port forward port 80 from your home router to your Plex server.
If you want to be super secure then use https on the reverse proxy by following this guide.