Overview
This document provides guidance on deploying a headless, shared, Plex Media Server. The deployment enables users to request new media via Discord or with access to Sonarr/Radarr. I recommend you do not expose Sonarr/Radarr to anyone besides sysop.
arr sends requests to Jackett to source a torrent which is piped to Deluge for download. Once downloads complete, Deluge will extract and move them to the rclone mountpoint.
Sequence Diagram
Assumptions
This document assumes you have a 100-200 level of familiarity with Ubuntu. It specifically assumes you are a reasonable & resourceful human being capable of googling things, while also understanding:
chmod
,chown
; more broadly - fixing Linux fs permissionsnano
(or your preferred text editor)apt-get
screen
ssh
- Headless Linux deployments
- IPv4, firewalling, routing
- Certificate-based authentication
If you are unsure, do yourself a favor and lookup these binaries/concepts as they relate to Ubuntu before proceeding.
Infrastructure & Deployment Guide
Pre-requisite Infrastructure
- Ubuntu host
- Public TCP/UDP access to port
32400
(Plex) - PRIVATE ACCESS (only your /32 IP should be routable) to ports
7181
(SSH),7878
(Radarr),8989
(Sonarr),8112
(Deluge),9117
(Jackett) - 64gb (or larger) performant boot drive
- Recommended: Several TBs of HDD attached storage for temporary storage of downloads. HDD is recommended for cost savings. Plex will serve media off the performant drive.
We will demonstrate deploying all services on a single host. Plex availability can be scaled out by deploying Plex Media Server and rclone on additional hosts in additional regions. Additional Plex regions need to be explicitly shared with your users.
Step 1: Deploy & prep the Ubuntu host
Deploy an Ubuntu host. Change the sshd
port on the host for secure access:
Look for #Port 22
and update it to #Port 7181
, or some other lesser-used port. Restart sshd
via systemctl
:
[!NOTE]
If you deployed the VM on a cloud host, ensure you properly configured the cloud firewall.
Now we need to create the mountpoints for rclone and the HDD direct-attach storage. I will name my rclone mountpoint gdrive
and the HDD mountpoint local
, both living in the home dir ~/
:
Now let's install/configure some other packages we will need:
We still need to install Plex, Jackett, Sonarr, and Radarr. Find guidance for installing those packages here (no sense in me rewriting these):
- Plex
- Sonarr
- Radarr - Use this community install script, it's simpler than the 'official' method
- Jackett
Lastly, we will download the java Discord bot. We will configure this a bit later, but may as well download the bits now.
Visit the Doplarr github repo and download the latest release:
[!NOTE]
You will not be able to complete theconfig.edn
file just yet. We will return to this later.
Step 2: Configure rclone and mount rclone
Use rclone config
to add a new profile. You should create your own OAuth credential with cloud providers, or use sftp for selfhosted storage. This guide assumes you configured an rclone profile named "gdrive".
[!NOTE]
Because we are using a headless machine, you will need to completerclone config
with your local machine. You will be prompted to specify headless authorization duringrclone config
. Ie - do not spam return through setup as headless authZ is not a default config option.
Use the following rclone mount command in a screen
to mount the rclone storage. The params in this command minimize the rclone tax on local storage and throttle bandwidth to stay under Google's API limits. If you're not using gdrive, you should spend a considerable amount of time researching the right params for your setup and expect much trial/error testing in finding the most stable route. rclone mount
will be a long running service which is why screen
usage is recommended.
Detach the screen
by pressing CTRL + A
, D
.
Step 3: Configure Plex
Plex serves at port 32400
by default. To configure the server and associate it with your plex account, we need to access localhost:32400
from the host itself - however - we are using a headless machine, therefore we need to use ssh -L
to forward port 32400
to our local machine:
Return to your local machine and open a new local terminal window. Use ssh -L
to forward port 32400
to your localhost:
[!NOTE]
-p
indicates the port thatsshd
listens on. We changed this to7181
in Step 1.
Now open a web browser in your local machine and navigate to https://localhost:32400
. You should see the plex web app launch (after signing in) and be routed to the server setup experience.
Create 2 Plex libraries, one named Movies
and one named TV
. Point each library toward its respectve ~/gdrive/Media
path that we setup earlier.
[!IMPORTANT]
IT IS IMPORTANT YOU SEPARATE MOVIES AND TV THIS WAY. Plex's background services responsible for processing newly-added media, finding subtitles, associating media metadata, and more, rely on this structure. Plex has separate agents for TVs and Movies.
After the initial server setup is complete, you do not need ssh -L
to continue administrating the server. You can sign into the host (assuming you can route to it) from any machine and your plex account permissions will grant you remote-admin capabilities.
Step 4: Configure Deluge
Deluge serves its web gui on port 8112
. Unlike Plex, we can access this gui from any remote machine (assuming the machine can route to it).
[!IMPORTANT]
Only deploy ONE instance of Deluge for your entire plex setup. If you're scaling out your plex hosts to serve media from different regions/geos, you do NOT configure Deluge (nor the Discord bot, or the arr software) on additional hosts. Because all completed media is moved to rclone's mountpoint, thus piped to Google Drive, the bits will automatically appear on other machines with the same rclone config.
Startup the deluge gui from a screen
with deluge-web
.
Detach screen with CTRL + A
, D
.
Navigate to http://[the vm host]:8112
. The default password for the gui is deluge
. Once signed in, change the password in preferences to something more secure.
From Deluge preferences, set the default download folder to ~/local/
. Go to Plugins
from the Deluge preferences and enable the Extractor
and Label
plugins. Close the preferences window.
At the bottom of the left-hand menu in Deluge, you should see a new section named Labels
. Expand the section and right-click on the section header (gray bar that says Labels). Create 2 labels: movie
and tv
. You will see both labels appear in the section content.
Right-click on each label and hit Label Options
. Navigate to the Folders
tab and configure Moved completed to:
to point toward the respective media folder in ~/gdrive
. E.g., the movie
label should move completed torrents to ~/gdrive/Media/Movies
. This is the directory where Plex will pickup new content and serve.
Step 5: Configure Jackett
Navigate to http://[the vm host]:9117
and use the Jackett documentation to configure Jackett with torrent trackers you have access to. Every tracker has a different config process. The process is self-explanatory within the Jackett gui.
You will ultimately need the Jackett API key and the Torznab feed URLs for all of your configured indexers to complete Step 6 below:
[!TIP]
Step 6: Configure Sonarr/Radarr
Sonarr and Radarr are part of the arr family of apps. They help you organize media and orchestrate the search + download of content. There are TONS of tutorials and videos online for setting these apps up with Deluge and Jackett, so google it. It's dead simple. You will need the API key from Jackett (find it in the top-right corner of the Jackett gui on port 9117
) and the password you set for deluge earlier.
Access Sonarr (TV Shows) at http://[the vm host]:8989
Access Radarr (Movies) at http://[the vm host]:7878
General Config Notes
In Media Management
, set your Root Folder pointing toward ~/local
:
[!TIP]
Download Client Setup Notes
When configuring Deluge as your download client in Sonarr/Radarr, be sure to fill in the Category
field of the Download Client profile in arr. For Sonarr, use tv
and for Radarr use movie
. This will ensure the tag is auto-applied in Deluge, and completed media will be automatically moved to the appropriate Plex folder in the rclone mountpoint.
Example Download Client config:
[!TIP]
Indexer Setup Notes
The arr indexer profiles are what connect to Jackett. You will need 1 arr profile for each Jackett source. You can also specify indexer priority from the arr advanced settings in this menu, enabling you to prioritize which of your tracker accounts' ratios you want to hit and in what order.
[!NOTE]
Be sure you select all the appropriate categories in the indexer config. I recommend selecting every category as the arr apps function as your primary user-facing download filter. Ie, the arr apps will not resolve a request for a Windows application.
[!TIP]
Copy the Torznab Feed from each Jackett Indexer and input it as its own Indexer within the arr app. Both Sonarr and Radarr each need individual indexer profiles for every indexer configured in Jackett.
Example Indexer config:
[!TIP]
Media Profiles
I also recommend you configure the Profiles
on Sonarr and Radarr. These dictate the media quality that is acceptable for download. Enabling 4K media will eat up TBs of storage quickly. Restricting low quality media will limit search results, particularly for older media where 720p (or worse) may be original quality. Think this through.
My recommended single-profile config:
[!TIP]
Config details:
[!TIP]
Step 7: Configure and run the Discord bot (Doplarr)
Return to the discord bot github repo and follow the instructions for setting the config.edn
file in ~/discord
. You will need the arr API keys (available from the arr gui's General Settings) and your Discord bot's key. Instructions for configuring the Discord bot app on Discord's website is in the Doplarr docs.
Your Sonarr/Radarr API keys are available in their settings gui, on the General
tab.
Example config.edn
below with fake API keys. Note that the leading-semicolon is comment-notation in the edn format.
After you set config.edn
, open a new screen
session and run the java file:
You should see the Discord bot join your server.
Detach the screen with CTRL + A
, D
.
Step 8: Share out Plex access
You're done!