Plex, for a multi-user multi-media system, lacks detailed logging and monitoring. A colleague recently pointed out to me that another system, PlexPY exists to fill that gap. This blog post will walk through the steps I took to integrate the system into my reverse proxy and setup init scripts.
Plexpy itself, has quite good documentation here (for initial setup) and here (for creating system init scripts).
Creating a new service:
This is straightforward, and can be done by following the documentation above. No changes were necessary to have it running on Ubuntu 16.04.
- Create the user to run the service:
sudo adduser --system --no-create-home plexpy
- Change the ownership of the file structure to allow the new user to modify the files:
sudo chown plexpy:nogroup -R /opt/plexpy
- Create the init script:
sudo vi /lib/systemd/system/plexpy.service
- Put the following in the file:
[Unit] Description=PlexPy - Stats for Plex Media Server usage [Service] ExecStart=/opt/plexpy/PlexPy.py --quiet --daemon --nolaunch --config /opt/plexpy/config.ini --datadir /opt/plexpy GuessMainPID=no Type=forking User=plexpy Group=nogroup [Install] WantedBy=multi-user.target
- Reload the services, enable plexpy and start it:
sudo systemctl daemon-reload; sudo systemctl enable plexpy.service; sudo service plexpy start
Configuring Apache reverse proxy to allow access:
- Shutdown Apache and PlexPY:
sudo service plexpy stop sudo service apache2 stop
- Change the settings in PlexPY to make it work behind a reverse proxy. Edit the config file and change the lines to:
http_root = /plexpy http_proxy = 1
- Edit your Apache reverse config file for the domain hosting plexpy:
ProxyPass /plexpy http://Local_IP_of_plexpy:8181/plexpy/ ProxyPassReverse /plexpy http://Local_IP_of_plexpy:8181/plexpy/
- Start the services again:
sudo service plexpy start sudo service apache2 start