How To Map Plex Media Server to Your Home Domain
Being the Über Geek that I am, reaching my home server from anywhere in the world is trivial.
I have all the appropriate port-forwarding in place for ssh
, ftp
, vnc
, and other miscellaneous ports for various different tasks and programs.
One such program is Plex, a media server that houses, manages and maintains my media collection.
When I want to access the Plex web client from teh internetz, I can simply type my home IP, port and path into any browser from anywhere in the world, login and Boom-Wow-Kapow™, I am in.
The Problem
While this process is great and easy for me as a software-engineer
, my wife, who is !software-engineer
should be able to watch Plex as easily as I can.
She shouldn't have to figure out the IP address of our home machine, remember which port to use or remember the relative path of the server.
She should be able to enter a simple url, such as http://plex.example.com
to get to Plex, so let's figure out how to do that.
- Complex
http://68.194.31.155:32400/web
- Easy
http://plex.example.com
The Solution
The first step is to make it easy for her to reach the home machine.
This one is easy as there is an entire infrastructure older than I am to match easy-to-remember names to hard-to-remember computer IP addresses: DNS.
First, I added a plex
subdomain to one of my existing domain names.
Then, I use a service called DynDNS to keep this subdomain up-to-date with my home's external IP address.
I could have written a script to do this for me, but I already had DynDNS setup for other reasons.
Now we are looking good:
- Good
http://plex.example.com:32400/web
The next step is to get rid of that pesky port.
To accomplish this, instead of having my router forward port 32400
to the server, I set it up to forward port 80
instead.
Port 80
is the default http
port, so omitting a port in the url is the same as using port 80
.
I wasn't using the server to host any other webpages, so hijacking the whole system to serve Plex was fine for me.
Port forwarding is only half the problem though.
Plex does not have a configuration setting to listen on port 80
, so I had to reconvert traffic on port 80
to redirect back to port 32400
.
You do this in your apache httpd.conf
file on the server.
From here on out the instructions are Mac OS X 10.8 specific.
It may work on *nix machines, but your mileage may vary.
I added the following code to /private/etc/apache2/httpd.conf
.
Then restart your apache by opening Terminal.app and running sudo apachectl restart
to apply the changes. This is taking all traffic on port 80
, then internally passing it off to port 32400
.
Now we are looking better:
- Better
http://plex.example.com/web
The next step is getting the /web
off the end. In the httpd.conf
file from above, add this snippet just before the closing VirtualHost
tag.
The X-Plex-Device
line is a clever bit from Spike Grobstein that allows the internal Plex Media Server communication to work still as it requires the Web
service url to be unaltered. Thanks for the comment Emmanuel Papin!
Then restart your apache by opening Terminal.app and running sudo apachectl restart
to apply the changes. This takes any url that does not start with /web
and rewrites it to /web
.
Now we are looking perfect:
- Perfect
http://plex.example.com
The final step is a bit of security. Because I have now opened up this server to the world, I need to put some password protection on it.
There are no bank passwords or crazy secrets on this media server, not even private home videos, so BASIC HTTP Auth
will do fine.
If you are following along this tutorial to setup your own server, I suggest you do the same.
In the httpd.conf
file from above, add this snippet just after the ServerName
line.
If you do not have a htpasswd
file created already (you probably don't), you can create one by running the following commands in Terminal.app
cd /private/etc/apache2
sudo htpasswd -bc htpasswd [username] [password]
(replace[username]
and[password]
with your desired username and password.)
Then restart your apache by opening Terminal.app and running sudo apachectl restart
to apply the changes.
Now you have an easy-to-remember, publicly accessible, secure URL for you home media server to watch The Walking Dead from anywhere in the world. Enjoy!
TL;DR
- Setup a DNS entry for
plex.yoursite.com
box using DynDNS. - Setup port forwarding on port
80
to your Mac server's port80
. - Add the following code within
private/etc/apache2/httpd.conf
then restart the server by runningsudo apachectl restart
Lastly, I run a small software company called Urban Apps. It pays the bills so I can take the time to write helpful posts like this one. If you found this page helpful at all, I would really appreciate it if you would check out my Apps on the iTunes App Store.
Was this page helpful for you? Buy me a slice of 🍕 to say thanks!
Comments