I have been using Plex for quite some time, and one of thing which was annoying to me was the way to access Plex.
The typical way Plex is accessed is via a local IP address at http://localipaddress:32400/web/. Changing the bit to make Plex available to the outside is a bad idea, as there is no restriction.
I wanted to do a redirection via my domain to have the following: http://plex.mydomain.com
It was not easy to find a solution, and i ended finding that I have to do a reverse proxy, and redirecting the address to the Plex server.
For this, luckily, I already had my Kubuntu virtual machine with Apache.
On top of that, a couple of days later, I stumbled on the very good article of Matt Coneybeare
The right way to do it securely is mentioned at the end of the article.
- Setup a DNS entry for plex.domain.com
box using the interface of your DNS provider
- Setup port forwarding on port 80
to your Plex server’s port 32400
.
- Add the following code within etc/apache2/httpd.conf:
<VirtualHost *:80>
ServerName plex.yoursite.com
<Location />
AuthType Basic
AuthName "Restricted area"
AuthUserFile /private/etc/apache2/htpasswd
Require valid-user
</Location>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:32400/
ProxyPassReverse / http://127.0.0.1:32400/
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/web
RewriteCond %{HTTP:X-Plex-Device} ^$
RewriteRule ^/$ /web/$1 [R,L]
</VirtualHost>
- If you do not have a htpasswd
file created already (you probably don’t), you can create one by running the following commands in the Terminal:
$ cd /private/etc/apache2
sudo htpasswd -bc htpasswd [username] [password]
Replace the username and password with what you would like
- Restart the server by running
$ sudo apachectl restart
Now you have a secure redirection for the Plex Web interface.
This will give you access to the Plex Web interface as if you were on your LAN.