Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rickklaasboer/b5c159833ff2971fccd32296d8ba2260 to your computer and use it in GitHub Desktop.
Save rickklaasboer/b5c159833ff2971fccd32296d8ba2260 to your computer and use it in GitHub Desktop.
How to setup Plex with Sonarr, Radarr, Jackett, Overseerr and qBitTorrent using Docker

How to setup Plex with Sonarr, Radarr, Jackett, Overseerr and qBitTorrent using Docker

This is a guide that will show you how to setup Plex Media Server with Sonarr, Radarr, Jackett, Overseerr and qBitTorrent with Docker. It is written for Ubuntu 20.04 but should work on other Linux distributions as well (considering supported distributions by Docker). It is also written for people who have some experience with Linux and Docker. If you are new to Docker, I recommend you to read the Docker documentation, and if you are new to Linux, I recommend you to read the Ubuntu documentation.

Now, let's get started!

Please note: This guide was written without considering hardlinking for Sonarr/Radarr. If you want to use hardlinking refer to #Hardlinking

Prerequisites

  • A server running Ubuntu 20.04 (with SSH access, and minimum requirements as defined by Plex)
  • A Plex account
  • A domain name (optional)

Table of contents

Installing Docker (with compose)

First, we need to install Docker. To do this, we need to run the following commands:

sudo apt update

sudo apt-get -yq install curl

# Install Docker
sudo curl -sSL https://get.docker.com/ | CHANNEL=stable bash
sudo systemctl enable docker --now


# Install docker-compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

# Enable swap
sudo sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="quiet"/GRUB_CMDLINE_LINUX_DEFAULT="quiet swapaccount=1"/g' /etc/default/grub
sudo update-grub

Now, make sure to reboot your server, otherwise Docker will not work properly.

sudo reboot

Installing Plex

Now, before installing Plex you should consider either containerizing plex or simply running it bare metal. If you want to run it bare metal, you can skip this step and go to the next one. If you want to containerize Plex, you can follow the steps below.

In my personal setup I run Plex bare metal, but I will show you how to containerize it as well.

Containerizing Plex

First, we need to create a docker-compose.yml file to define our Plex container. You'll need to create a new directory for this, which can be stored on your server anywhere you want. I personally store all my docker-compose files in /opt/docker/. Place this file in the directory you just created.

Please note: we will be creating this docker-compose.yml in multiple steps, if you want the entire file now you can skip to the end of this tutorial.

I'll mostly be using docker images created by linuxserver on Docker Hub, since they are well maintained and have a lot of features. You can find the Plex image here.

First, create a folder inside the directory you just created called plex. This is where we will store the configuration files for Plex. Now, open the docker-compose.yml file you just created and paste the following content in it:

version: "3"
services:
    plex:
        image: lscr.io/linuxserver/plex:latest
        container_name: plex
        network_mode: host # Change this to bridge if you don't want Plex to run on your host network.
        environment:
            - PUID=1000 # Change this to your user ID
            - PGID=1000 # Change this to your group ID
            - TZ=Etc/UTC # Change this to your timezone
            - VERSION=docker
            - PLEX_CLAIM= #optional
        volumes:
            - /opt/docker/plex:/config
            - /path/to/tvseries:/tv # Change this to your TV series directory
            - /path/to/movies:/movies # Change this to your movies directory
        restart: unless-stopped

If you're not running Plex in host network mode, you'll have to expose some ports. To do this, add the following lines to the docker-compose.yml file:

ports:
    - 32400:32400/tcp
    - 32469:32469/udp

These will also need to be allowed in your firewall, if you're using UFW you can run the following commands:

sudo ufw allow 32400/tcp
sudo ufw allow 32469/udp
sudo ufw reload

I will not be going over how to configure Plex any further, since it is pretty straightforward. You can find more information about the configuration and how-to on the Techno Tim YouTube channel.

Running Plex bare metal

If you want to run Plex bare metal, you can follow the steps below.

First, we need to add the Plex repository to our system. To do this, we need to run the following commands:

echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list

Once we've added the repository, update the package list and install Plex.

sudo apt update

sudo apt install plexmediaserver

To verify plex is running, you can run the following command:

sudo systemctl status plexmediaserver

Output should look something like this if Plex is running:

plexmediaserver.service - Plex Media Server
    Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
    Active: active (running) since Thu 2021-06-17 19:36:33 UTC; 23min ago

Don't worry if the output is different, as long as it says active (running) Plex is running.

Now, you'll have to update some firewall rules to allow Plex to be accessible from the outside. To do this, we need to run the following commands:

sudo ufw allow 32400/tcp
sudo ufw reload

Now, you should be able to access Plex from the outside. To do this, go to http://<your-server-ip>:32400/web in your browser. If you want to access Plex from a domain name, you can follow the steps in the Configuring Nginx/Caddy section. This is optional, but I recommend you to do it, since it will make your life easier.

Please note that you will need to create a Plex account to be able to use Plex. You can create one here. Also, our docker containers are not yet running. We will be configuring and starting them in the next steps.

Installing qBitTorrent

qBitTorrent is a torrent client, we will be using this to download torrents for Plex. We're using qBitTorrent since it provides us with a handy web interface and API, which both Sonarr and Radarr require. All completely legal, of course.

Now, we need to install qBitTorrent. We'll be using a docker image created by dyonr for this. You can find the image here. If you don't want to use a VPN, you can use the image created by linuxserver here.

Please note: If you're going to use this setup to download not-so-legal content, I recommend you to use a VPN, but of course you won't be doing this because it's illegal πŸ˜‰. Now, if you don't have a VPN yet, I'd recommend using either Mullvad or ProtonVPN. I'm personally using Private Internet Access, but ever since they got bought by another company I can't really recommended them anymore. Other VPN services work fine aswell, just make sure they either support OpenVPN or WireGuard.

To get started, expand your previously created directory with the docker-compose.yml file. Create a new directory called qbittorrent. This is where we will store the configuration files for qBitTorrent. Now, open the docker-compose.yml file you just created and paste the following content in it, inside the services section:

Please note: for this step you'll also need a folder in which qBitTorrent will store the downloaded files, I recommend you to create a folder called downloads alongside the tv and movies folder you created for Plex.

---
qbittorrent:
    image: dyonr/qbittorrentvpn
    restart: unless-stopped
    privileged: true
    volumes:
        - /opt/docker/plex/qbittorrent:/config
        - /path/to/plex/downloads:/downloads # Change this to your downloads directory
    environment:
        - PUID=1000 # Change this to your user ID
        - PGID=1000 # Change this to your group ID
        - VPN_ENABLED=yes
        - VPN_TYPE=openvpn # Change this to wireguard if you want to use WireGuard
        - LAN_NETWORK=192.168.2.0/24 # Change this to your LAN network
        - NAME_SERVERS=1.1.1.1,1.0.0.1 # Optionally, change this to your preferred DNS servers
        - ENABLE_SSL=no # Change this to yes if you want to use SSL
        - HEALTH_CHECK_HOST=one.one.one.one # Optionally, change this to your preferred health check host
    ports:
        - 8080:8080

This Docker image requires you to setup either a WireGuard profile or an OpenVPN profile. Depending on which VPN you use, you'll need to follow the steps defined by your VPN provider. Most likely, they will provide you with a downloadable profile. Place that file in the qbittorrent/{openvpn,wireguard} directory you created earlier. You should also create a credentials file, which should be placed in the same directory. The credentials file should contain the following:

<username>
<password>

But then again, please revert to the documentation of your VPN provider to see how to configure the VPN.

Once the containers are running (which we will be doing in a later step), qBitTorrent should be available at http://<your-server-ip>:8080. You probably don't want this to be accessible from the outside, so I'd recommend against setting up a reverse proxy for this.

Installing Sonarr

Sonarr is a service that allows you to automatically download TV series. We will be using this to automatically download TV series for Plex. Again, all completely legal, of course.

Next, we will need to install Sonarr. We'll be using a docker image created by linuxserver for this. You can find the image here.

To get started, expand your previously created directory with the docker-compose.yml file. Create a new directory called sonarr. This is where we will store the configuration files for Sonarr. Now, open the docker-compose.yml file you just created and paste the following content in it, inside the services section:

...
    sonarr:
        image: lscr.io/linuxserver/sonarr:latest
        container_name: sonarr
        environment:
            - PUID=1000 # Change this to your user ID
            - PGID=1000 # Change this to your group ID
            - TZ=Etc/UTC # Change this to your timezone
        volumes:
            - /opt/docker/plex/sonarr:/config
            - /path/to/plex/tv:/tv # Change this to your TV series directory
            - /path/to/plex/downloads:/downloads # Change this to your downloads directory
        ports:
            - 8989:8989
        restart: unless-stopped
    ```

We will be configuring Sonarr in a later step. Once the containers are running, Sonarr should be available at http://<your-server-ip>:8989. You probably don't want this to be accessible from the outside, so I'd recommend against setting up a reverse proxy for this.

Installing Radarr

Radarr is basically the same as Sonarr, but for movies.

Next, we will need to install Radarr. We'll be using a docker image created by linuxserver for this. You can find the image here.

To get started, expand your previously created directory with the docker-compose.yml file. Create a new directory called radarr. This is where we will store the configuration files for Radarr. Now, open the docker-compose.yml file you just created and paste the following content in it, inside the services section:

---
radarr:
    image: lscr.io/linuxserver/radarr:latest
    container_name: radarr
    environment:
        - PUID=1000 # Change this to your user ID
        - PGID=1000 # Change this to your group ID
        - TZ=Etc/UTC # Change this to your timezone
    volumes:
        - /opt/docker/plex/radarr:/config
        - /path/to/plex/movies:/movies
        - /path/to/plex/downloads:/downloads
    ports:
        - 7878:7878
    restart: unless-stopped

We will be configuring Radarr in a later step. Once the containers are running, Radarr should be available at http://<your-server-ip>:7878. You probably don't want this to be accessible from the outside, so I'd recommend against setting up a reverse proxy for this.

Installing Jackett

Jackett is a service that allows you to search for torrents on multiple torrent sites at once, we will be using this to search for (completely legal) torrents in Sonarr and Radarr.

Next, we will need to install Jackett. We'll be using a docker image created by linuxserver for this. You can find the image here.

To get started, expand your previously created directory with the docker-compose.yml file. Create a new directory called jackett. This is where we will store the configuration files for Jackett. Now, open the docker-compose.yml file you just created and paste the following content in it, inside the services section:

jackett:
    image: lscr.io/linuxserver/jackett:latest
    container_name: jackett
    environment:
        - PUID=1000 # Change this to your user ID
        - PGID=1000 # Change this to your group ID
        - TZ=Etc/UTC # Change this to your timezone
        - AUTO_UPDATE=true
    volumes:
        - /opt/pvr/jackett:/config
        - /mnt/plex/downloads:/downloads
    ports:
        - 9117:9117
    restart: unless-stopped

Installing Overseerr

Finally, we will need to install Overseerr. We'll be using a docker image created by sct for this. You can find the image here.

Overseerr is a service that allows you to request TV series and movies, we will be using this to allow our users to request TV series and movies for Plex. Again, all completely legal, of course.

To get started, expand your previously created directory with the docker-compose.yml file. Create a new directory called overseerr. This is where we will store the configuration files for Overseerr. Now, open the docker-compose.yml file you just created and paste the following content in it, inside the services section:

---
overseerr:
    image: lscr.io/linuxserver/overseerr:latest
    container_name: overseerr
    environment:
        - PUID=1000 # Change this to your user ID
        - PGID=1000 # Change this to your group ID
        - TZ=Etc/UTC # Change this to your timezone
    volumes:
        - /opt/docker/plex/overseerr:/config
    ports:
        - 5055:5055
    restart: unless-stopped

We will be configuring Overseerr in a later step. Once the containers are running, Overseerr should be available at http://<your-server-ip>:5055. Overseerr can be (and probably should be) accessed from the outside, since you and potentially other users will be requesting media from here. so I'd recommend setting up a reverse proxy for this. You can find more information about this in the Configuring Nginx/Caddy section.

Let's run it!

Once you've created all the directories and added all the services to the docker-compose.yml file, it's time to run it! To do this, we need to run the following command:

docker-compose up -d

This will start all the containers in the background. If you want to see the logs of the containers, you can run the following command:

docker-compose logs <container_name>

Once all the containers are up and running, you should be able to access the services from your browser. If your host machine is using a firewall, make sure to allow the ports you've exposed in the docker-compose.yml file.

Just for reference, your docker-compose.yml should look something like this:

version: "3"
services:
    qbittorrent:
        restart: unless-stopped
        privileged: true
        volumes:
            - /opt/pvr/qbittorrent:/config
            - /mnt/plex/downloads:/downloads
        environment:
            - PUID=1000
            - PGID=1000
            - VPN_ENABLED=yes
            - VPN_TYPE=openvpn
            - LAN_NETWORK=192.168.2.0/24
            - NAME_SERVERS=1.1.1.1,1.0.0.1
            - ENABLE_SSL=no
            - HEALTH_CHECK_HOST=one.one.one.one
        ports:
            - 8080:8080
        image: dyonr/qbittorrentvpn
    sonarr:
        image: lscr.io/linuxserver/sonarr:latest
        container_name: sonarr
        environment:
            - PUID=1000
            - PGID=1000
            - TZ=Etc/UTC
        volumes:
            - /opt/pvr/sonarr:/config
            - /mnt/plex/tv:/tv
            - /mnt/plex/downloads:/downloads
        ports:
            - 8989:8989
        restart: unless-stopped
    radarr:
        image: lscr.io/linuxserver/radarr:latest
        container_name: radarr
        environment:
            - PUID=1000
            - PGID=1000
            - TZ=Etc/UTC
        volumes:
            - /opt/pvr/radarr:/config
            - /mnt/plex/movies:/movies
            - /mnt/plex/downloads:/downloads
        ports:
            - 7878:7878
        restart: unless-stopped
    jackett:
        image: lscr.io/linuxserver/jackett:latest
        container_name: jackett
        environment:
            - PUID=1000
            - PGID=1000
            - TZ=Etc/UTC
            - AUTO_UPDATE=true
        volumes:
            - /opt/pvr/jackett:/config
            - /mnt/plex/downloads:/downloads
        ports:
            - 9117:9117
        restart: unless-stopped
    overseerr:
        image: lscr.io/linuxserver/overseerr:latest
        container_name: overseerr
        environment:
            - PUID=1000
            - PGID=1000
            - TZ=Etc/UTC
        volumes:
            - /opt/pvr/overseerr:/config
        ports:
            - 5055:5055
        restart: unless-stopped

Depending if you're using Plex bare metal or not, you'll also find the plex service in this file.

Configuring Plex

Not much has to be changed from the default Plex configuration, but there are some things that need to be changed.

First, we need to make sure that Plex is allowed to use both the /tv and /movies directories. To do this, go into the Plex web interface and go to Settings > Libraries. Click on Add Library and select TV Shows or Movies. Now, select the /tv or /movies directory and click Add Library. Repeat this for the other directory.

If your directories are not showing up, you might need to change the permissions of the directories. To do this, run the following commands:

sudo chown -R plex:plex /path/to/plex/tv
sudo chown -R plex:plex /path/to/plex/movies

Also make sure Scan my library automatically is enabled. This will make sure that Plex will automatically scan for new media. To do this, go to Settings > Library and make sure Scan my library automatically is enabled.

That should basically be it for Plex configuration.

Configuring qBitTorrent

Now, we need to configure qBitTorrent. To do this, go to http://<your-server-ip>:8080 in your browser. It will prompt for a username and password, the default username is admin and password adminadmin. If you're going to make this accessible from the outside, I recommend you to change this.

Luckily, basically nothing has to be configured here. Yay!

Configuring Sonarr

Now, we need to configure Sonarr. To do this, go to http://<your-server-ip>:8989 in your browser. Our docker image doesn't enable authentication by default, if you're only using Sonarr locally this is fine, but if you're going to make this accessible from the outside I recommend you to enable authentication. To do this, go to Settings > General and change the Authentication setting to Forms (Login Page) or Basic (Browser Popup) and follow the provided steps. Please note a restart is required for this to take effect.

Now, we need to add our download client. To do this, go to Settings > Download Clients and click on the + icon. Select qBittorrent and click Next. Now, enter the following information:

  • Name: qBittorrent
  • Host: qbittorrent
  • Port: 8080
  • Username: admin
  • Password: adminadmin
  • Category: tv-sonarr

And if you're using SSL you should enable this too.

Now, click Test and if everything is configured correctly you should see a green checkmark. If you don't, make sure you've entered the correct information and that qBitTorrent is running. Then, click Save.

We will be configuring the indexer(s) in a later step, since this requires Jackett to be configured and running.

Configuring Radarr

Now, we need to configure Radarr, which is basically the same as Sonarr. To do this, go to http://<your-server-ip>:7878 in your browser. Our docker image doesn't enable authentication by default, if you're only using Radarr locally this is fine, but if you're going to make this accessible from the outside I recommend you to enable authentication. To do this, go to Settings > General and change the Authentication setting to Forms (Login Page) or Basic (Browser Popup) and follow the provided steps. Please note a restart is required for this to take effect.

Again, we need to add our download client. To do this, go to Settings > Download Clients and click on the + icon. Select qBittorrent and click Next. Now, enter the following information:

  • Name: qBittorrent
  • Host: qbittorrent
  • Username: admin
  • Password: adminadmin
  • Category: radarr

And again if you're using SSL you should enable this too.

Now, click Test and if everything is configured correctly you should see a green checkmark. If you don't, make sure you've entered the correct information and that qBitTorrent is running. Then, click Save.

We will be configuring the indexer(s) in a later step, since this requires Jackett to be configured and running.

Configuring Jackett

Then, we need to configure Jackett. To do this, go to http://<your-server-ip>:9117 in your browser. I'd advise against exposing this to the outside, since it's not really necessary, but definitly very illegal. The provided Docker image sets us up with a default Jackett installation, so we don't have to do much here.

Basically, just add your preferred indexers, you can do this by clicking on the + Add indexer icon in the top right corner. Now I won't be recommending any indexers since, of course, that would be illegal. If you're looking for a list you should definitely avoid, you can find one here, here and here. Again, you should AVOID this list at all costs. We don't want to do anything illegal, right?

Next, we need to add our 100% legal indexers to Sonarr and Radarr. These steps can be repeated for all indexers and for both Sonarr and Radarr. To do this, go to Settings > Indexers and click on the + icon. Select Torznab and click Next. Now, enter the following information:

  • Name: The name of the indexer
  • Enable RSS: Yes
  • Enable Automatic Search: Yes
  • Enable Interactive Search: Yes
  • URL: http://jackett:9117/api/v2.0/indexers/<indexer_name>/results/torznab/
  • API Key: <jackett_api_key> (this can be found in the top-right corner of the Jackett web interface)
  • Categories: select relevant categories
  • Anime Categories: select relevant categories
  • Anime standard format search: Optional, can be left disabled. I'm not using this, but if you want to use this you should enable it.
  • Tags: Optional, can be left empty.

Now, click Test and if everything is configured correctly you should see a green checkmark. If you don't, make sure you've entered the correct information and that Jackett is running. Then, click Save.

Repeat this for all indexers you want to add.

Configuring Overseerr

Finally, we need to configure Overseerr. To do this, go to http://<your-server-ip>:5055 in your browser. Then, follow the setup guide as per the instructions on the screen. Once you've completed the setup, Overseerr should be (almost) ready to use.

Just for reference, follow the steps as follows:

  • Sign in with Plex, using the same Plex account you used to setup Plex.
  • Enter your server name, this can be anything you want.
  • Click the 'Scan' button next to the server section, this will scan for plex servers on your network. If I were you I'd choose the local option that will show up here.
  • Fill in the port where Plex is running, by default this is 32400.
  • If you're using SSL, enable this too.
  • Click the Sync Libraries inside the Plex Libraries section, this will scan for libraries on your Plex server. If you've followed this guide, you should see two libraries here, one for TV series and one for movies. Select both of them.
  • Now click, Start scan, this will start scanning your Plex libraries for media. This scan will be running on the background so you can continue with the setup.
  • Click Continue
  • Add your Radarr server.
    • Check the Default server options, since this is probably the only server you'll be using.
    • Enter a Server Name, this can be anything you want.
    • Enter the URL, this should be http://radarr if you're using the docker-compose file provided in this guide.
    • Enter the port, this should be 7878 if you're using the docker-compose file provided in this guide.
    • Enter the API key, this can be found in the Radarr web interface under Settings > General > Security.
    • For Quality profile, choose Any or your preffered quality profile.
    • For Root folder, choose the root folder of your movies library. If you've followed this guide, this should be /movies.
    • For Minimum Availability, choose Released.
    • For External URL put in http://<your-server-ip>:7878 if you're not using a reverse proxy, otherwise put in the URL of your reverse proxy.
    • Finally, check Enable automatic search
    • Click Test
    • If everything is configured correctly, you should see a green checkmark. If you don't, make sure you've entered the correct information and that Radarr is running. Then, click Save.
  • Add your Sonarr server.
    • Check the Default server options, since this is probably the only server you'll be using.
    • Enter a Server Name, this can be anything you want.
    • Enter the URL, this should be http://sonarr if you're using the docker-compose file provided in this guide.
    • Enter the port, this should be 8989 if you're using the docker-compose file provided in this guide.
    • Enter the API key, this can be found in the Radarr web interface under Settings > General > Security.
    • For Quality profile, choose Any or your preffered quality profile.
    • For Root folder, choose the root folder of your movies library. If you've followed this guide, this should be /tv.
    • For Minimum Availability, choose Released.
    • For External URL put in http://<your-server-ip>:8989 if you're not using a reverse proxy, otherwise put in the URL of your reverse proxy.
    • Finally, check Enable automatic search
    • Click Test
    • If everything is configured correctly, you should see a green checkmark. If you don't, make sure you've entered the correct information and that Radarr is running. Then, click Save.

Once this is finished, you'll be greeted by the Overseerr homepage. Something Overseerr probably borked during install is your Plex URL. To correct this, head into Settings > Plex and change Web App URL to:

  • http://<your-server-ip>:32400/web if you're not using a reverse proxy.
  • https://<your-domain-name>/web if you're using a reverse proxy.

Now, Overseerr should be ready to use, nice going! πŸŽ‰

Configuring Nginx/Caddy (optional)

Before continuing with this section, make sure you've completed the Configuring Plex, Configuring Sonarr, Configuring Radarr and Configuring Overseerr sections.

Also, you should probably get a domain name, I recommend using Cloudflare. If you don't want to use a domain name, you can skip this section. Whilst it is possible to use NGINX without a domain name, there really isn't much point in doing so.

I won't be going over how to install NGINX or Caddy here, since there are already a lot of guides on the internet on how to do this. I personally use Caddy, but NGINX works just as well. If you're using Caddy, SSL will be enabled by default, if you're using NGINX you'll have to configure this yourself.

A great guide on how to install NGINX can be found here, and another on how to install Caddy can be found here.

Now, we need to configure NGINX/Caddy. This is relatively easy, but can be a bit tricky if you're not familiar with NGINX/Caddy. But don't worry, I'll guide you through it.

First, we need to create a configuration file for our reverse proxy. I personally store all my NGINX/Caddy configuration files in /etc/nginx/sites-available/ or /etc/caddy/vhosts/. Create a new file called plex.conf and paste the following content in it:

Nginx

# /etc/nginx/sites-available/plex.conf
server {
  listen 80;
  listen 443 ssl;
  listen [::]:80;
  listen [::]:443 ssl;

  server_name <plex.your-domain.com>; # Change this to your domain name

  ssl_certificate /etc/letsencrypt/live/<your-domain>/fullchain.pem; # Change this to your SSL certificate
  ssl_certificate_key /etc/letsencrypt/live/<your-domain>/privkey.pem; # Change this to your SSL certificate key
  include /etc/letsencrypt/options-ssl-nginx.conf;

  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://<your-plex-ip-address>:32400;
  }

  if ($scheme != "https") {
    return 301 https://$host$request_uri;
  }
}

Please note: I'm using SSL here, so you'll have to get an SSL certificate. I recommend using Let's Encrypt, since it's free and easy to use. If you're using Caddy, you don't have to worry about this, since Caddy will automatically generate an SSL certificate for you.

Caddy

# /etc/caddy/vhosts/plex.conf
example.com {
    header_up Host {host}
    header_up X-Real-IP {remote}

    # We don't need to set the X-Forwarded-For and X-Forwarded-Proto headers
    # Caddy does this automatically.

	reverse_proxy <your-plex-ip-address>:32400
}

Also make sure include this new vhost in the main caddy file, you can do this as follows:

# /etc/caddy/Caddyfile

# Import all "virtual hosts"
import /etc/caddy/vhosts/*.conf

Don't forget to restart NGINX/Caddy after you've made these changes.

Our Plex app isn't ready to be used with a reverse proxy yet, because we didn't add any records to Cloudflare yet. We'll be doing this in the next step.

Configuring Cloudflare (optional)

Since you're probably running Plex from home, we don't want to expose our home IP address to the outside world. To do this, we can use Cloudflare. Cloudflare will act as a proxy between your server and the outside world, so your home IP address will be hidden. This is also useful if you don't have a static IP address, since you can just change the IP address in Cloudflare and you're good to go.

First, we need to create a Cloudflare account. You can do this here.

Next, we need to add our domain name to Cloudflare. to do this, head to the Websites tab and click + Add a site. Now, enter your domain name and click Add site. Now, Cloudflare will scan your domain name and add all the DNS records it can find. If you're using Cloudflare for the first time, this might take a while.

Next, complete the setup guide. You can skip the Speed up your site and Protect your site from attacks steps, since we won't be using these features (for now). Once finshed, Cloudflare will prompt you to change your nameservers to the Cloudflare nameservers. To do this, go to your domain name registrar and change the nameservers to the ones provided by Cloudflare. This might take a while to take effect, but once it does you should be able to access your domain name.

Next, head into your domain and click DNS, here we will add the DNS records for our services. To do this, click + Add record and enter the following information:

Type Name Content Proxy Status TTL Note
A plex <your-server-ip> Proxied Auto N/A
AAAA plex <your-server-ip> Proxied Auto Only if you have an IPv6 address

Finally, click Save.

At last, you should be able to access Plex from https://plex.example.com/web!

Updating the services

Once in a while, you'll have to update the services. This is pretty easy, but can be a bit tricky if you're not familiar with Docker. But don't worry, I'll guide you through it.

First, we need to stop the containers. To do this, run the following command:

docker-compose down

Then, we need to update the docker images. To do this, run the following command:

docker-compose pull

This will pull the latest images for all the services. Once this is done, we need to restart the containers. To do this, run the following command:

docker-compose up -d

This will restart all the containers, you should now be good to go!

Hardlinking

Hardlinking is a technique used by Sonarr and Radarr to save disk space. It basically creates a hardlink to the original file, instead of copying the file. This means that if you download a file with Sonarr or Radarr, the file will be saved in the downloads directory, but also in the TV series or movies directory. The actual directory on our host machine doesn't matter, as long as the same directory structure inside the container is used.

Previously, this guide was written without hardlinking, but I've decided to add it since it's a very useful feature. To enable hardlinking, we need to change some settings in Sonarr and Radarr.

First, make sure hardlinking is enabled in both Sonarr and Radarr. To do this, go to Settings > Media Management and make sure Use Hardlinks instead of Copy is enabled. If you don't see this option, make sure Advanced Settings is enabled.

While we're at it, you should probably go ahead and enable renaming. To do this, go to Settings > Media Management and make sure Rename Episodes (or Rename Movies in Radarr) is enabled. If you don't see this option, make sure Advanced Settings is enabled.

Then, stop your containers by running the following command:

docker-compose down

Now, we'll have to make some edits inside of the docker-compose file. To do this, open the docker-compose.yml file. Find your Sonarr and Radarr service and remove/edit the following lines:

sonarr:
  image: lscr.io/linuxserver/sonarr:latest
  container_name: sonarr
  environment:
    - PUID=1000
    - PGID=1000
    - TZ=Etc/UTC
  volumes:
    - /opt/pvr/sonarr:/config
-   - /mnt/plex/tv:/movies
-   - /mnt/plex/downloads:/downloads
+   - /mnt/plex:/data
  ports:
    - 8989:8989
  restart: unless-stopped
radarr:
  image: lscr.io/linuxserver/radarr:latest
  container_name: radarr
  environment:
    - PUID=1000
    - PGID=1000
    - TZ=Etc/UTC
  volumes:
    - /opt/pvr/radarr:/config
-   - /mnt/plex/movies:/movies
-   - /mnt/plex/downloads:/downloads
+   - /mnt/plex:/data
  ports:
    - 7878:7878
  restart: unless-stopped

Basically, we're removing the /movies and /downloads directories and replacing them with /data. This will allow Sonarr and Radarr to create hardlinks to the original file, instead of copying the file. You might be asking yourself as to why this is, it basically boils down to that Sonarr and Radarr can't create hardlinks to files that are not in the same directory. So, we're creating a directory that contains both the TV series and movies directory, as well as the downloads directory.

This way, they are technically in the same directory, thus making it possible to create hardlinks. For more information please refer to Trash Guides hardlinking manual.

Next, we have to edit our qBitTorrent service a bit, since we've changed the downloads directory. To do this, open the docker-compose.yml file. Find your qBitTorrent service and remove/edit the following lines:

qbittorrent:
  restart: unless-stopped
  privileged: true
  volumes:
    - /opt/pvr/qbittorrent:/config
-   - /mnt/plex/downloads:/downloads
+   - /mnt/plex/downloads:/data/downloads
  environment:
    - PUID=1000
    - PGID=1000
    - VPN_ENABLED=yes
    - VPN_TYPE=openvpn
    - LAN_NETWORK=192.168.2.0/24
    - NAME_SERVERS=1.1.1.1,1.0.0.1
    - ENABLE_SSL=no
    - HEALTH_CHECK_HOST=one.one.one.one
  ports:
    - 8080:8080
  image: dyonr/qbittorrentvpn

This way, our downloads map will also be in the /data directory, which will allow Sonarr and Radarr to create hardlinks to the original file, instead of copying the file. Again, saving lots of disk space. When this is done, we're ready to spin up our containers again.

To do this, run the following command:

docker-compose up -d

Now, head into your qBitTorrent web interface and change the downloads directory to /data/downloads. To do this, go to Settings > Downloads and change the Default Save Path to /data/downloads. Then, click Apply. If you've got Keep incomplete torrents in: checked, also update this directory.

Unfortunately, we're not done yet. We have to tweak some settings inside Radarr and Sonarr. Since we've moved the root folder location, remove the previously defined root folder and recreate it. To do this, go to Settings > Media Management and remove the previously defined root folder. Then click Add Root Folder and choose your newly created /data/{movies,tv} directory. Then, click Ok. You should repeat this step for both Sonarr and Radarr.

You'll probably have to rescan your libraries, this process is a little different for both Sonarr and Radar, so I'll explain both.

Sonarr

First, go into your Series tab and click the Mass Editor section. Now, select all your series and change the root folder to your newly created /data/tv directory. That should be it for Sonarr. If you like, you can also trigger a rename here (this would be the perfect time to do so, since we're recreating our library anyway).

Radarr

First, go into your Movies tab and click the Edit Movies button on the navigation bar, next click Select all. Now, in the bottom left click Edit and chanhge the root folder to your newly created /data/movies directory. Then click Apply Changes. That should be it for Radarr. Again, if you like, you can also trigger a rename here (this would be the perfect time to do so, since we're recreating our library anyway).

Once this is done, all warnings and errors should be gone from both Sonarr and Radarr, if not, make sure you've followed all the steps correctly. If you're still having issues, feel free to contact me, I'm always happy to help!

Now would be a good time to check if Plex has picked up the changes. To do this, go to Settings > Libraries and click on the Scan Library Files button. This will trigger a rescan of all your libraries. If you've followed this guide, you should see two libraries here, one for TV series and one for movies.

We're not quite done yet!, if you're running Overseerr like this guide described, you'll probably have to change some settings inside Overseerr. To do this, go to Settings > Services and click edit for both Sonarr and Radarr. Now, change the Root Folder to your newly created /data/{movies,tv} directory. Then, click Save Changes.

As of now, you've probably got a lot of missing files in qBitTorrent, feel free to purge these from your downloads directory. Since we didn't have hardlinking enabled previously, nothing will be lost here.

That's it! Sonarr and Radarr should be ready to use with hardlinking enabled, nice going! πŸŽ‰

Thank you

Well, that's it! You've successfully setup your own Plex server with Sonarr, Radarr, Jackett, Overseerr and qBitTorrent using Docker. If you have any questions, feel free to contact me, I'm always happy to help! At this time, I'm not planning on adding any more services to this guide, but if you have any suggestions feel free to contact me. I'm always open to suggestions! πŸ˜„

Again, please make sure you're not doing anything illegal, since that would be a real shame. Nonetheless, if you're going to do something illegal, I'm not responsible for anything that happens. You've been warned. πŸ˜‰

Also, many thanks to our friends at linuxserver for providing us with these awesome Docker images. If you want to support them, you can do so here.

And last but not least, thank you for reading this guide! I hope you've learned something from it. If you did, please consider dropping a follow on GitHub or follow me on Twitter. It would be greatly appreciated!

@rickklaasboer
Copy link
Author

rickklaasboer commented May 13, 2024

@neonoatmeal Hey! I think you've got the folders setup incorrectly, the structure should be as follows (please note the qbittorrent folder):

.
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ jackett
β”œβ”€β”€ overseerr
β”œβ”€β”€ prowlarr
β”œβ”€β”€ qbittorrent
β”‚Β Β  β”œβ”€β”€ openvpn
β”‚Β Β  β”‚Β Β  β”œβ”€β”€ credentials.conf
β”‚Β Β  β”‚Β Β  └── your_openvpn_file.ovpn
β”œβ”€β”€ radarr
β”œβ”€β”€ recyclarr
β”œβ”€β”€ sonarr
β”œβ”€β”€ tautulli

@neonoatmeal
Copy link

@rickklaasboer That did it! Thank you!! Excellent guide, btw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment