TrueNAS is Awesome
My experience migrating my home lab from Windows Server to TrueNAS
Recently, I decided that I wanted to move away from Google Drive and Google Calendar, primarily for privacy reasons. I started searching around for a self-hosted alternative, because I wanted to be in full control of my data, and I came across Nextcloud, which perfectly fit my use-case, with one caveat; it only runs on Unix systems, and I was running Windows Server on my home lab server at the time.
I decided that since the only thing I was running on my server at the time was Plex, I’d migrate to a Unix-based server, as Plex runs on both systems. A friend of mine who does this kind of stuff for a living recommended me TrueNAS, so I thought I’d give it a shot. Turns out, it’s freaking awesome.
The process of installing TrueNAS is more or less the same as installing a Linus distribution. Download the TrueNAS ISO, use something like Balena Etcher to flash the ISO onto a USB drive, then boot your machine from the USB to install TrueNAS. IF you need more guidance getting this set up, refer to the TrueNAS documentation.
Using a Domain Name with Subdomains
Since I would now be running multiple services off of the same machine with a single local IP address, and I wanted to map subdomains of my domain name to services, I need to run a reverse proxy server, for which NGINX is my go-to. I really like NGINX because the configuration syntax is more easily human-readable than others I’ve used, and you can easily break your configuration into multiple reusable snippets which can be imported into other configuration files.
I’m using my reverse proxy for SSL termination, so that I don’t need separate SSL certificates for each service, as well as mapping subdomains of my domain name to each service. For example, plex.my-domain.com points to my plex server, and nextcloud.my-domain.com points to my Nextcloud server. I’m using SSL certificates provided by my domain name registrar, but you can also easily get free SSL certs from Let’s Encrypt using certbot with the NGINX plugin. I have my NGINX reverse proxy server running in a TrueNAS Jail, and it was pretty simple to set up by basing my configuration on this guide.
You’ll also need to configure your network router to port-forward ports 80 and 443 (the ports used by HTTP and HTTPS, respectively) if you want to be able to access your server from outside your local network.
Setting Up Plex
Setting up Plex in TrueNAS was dead simple. TrueNAS has a plugin system which basically helps you to spin up pre-configured Jails. Using the TrueNAS Plex plugin, getting the Plex Media Server running was as simple as a couple of clicks. From the TrueNAS web UI, head to Plugins, then select the Plex Media Server plugin, and click Install.
Then, give your Jail a name (like “plex”), select DHCP, and click Save.
After creating the Jail, you can head to Jails, and click the arrow on the right to expand the Jail details to get the Jail’s local IP address. You’ll want to copy that IP address and map it as a static route on your network router, so that the DHCP server doesn’t change the Jail’s IP address when a network change occurs.
Once you have this IP, you’ll need to set the appropriate IP address for the appropriate subdomain in your reverse-proxy server, if you’re using one. For example, I have the following configuration in my
nginx.conf which will proxy requests to
https://plex.my-domain.com and forward them to the Plex server running in the Jail.
That’s pretty much all there is to getting Plex running. Then you can navigate to https://plex.my-domain.com and set up your libraries. Running Plex within a system like TrueNAS has an awesome added benefit; you can create a Samba share pointing to your Plex content directory within the jail, which will allow you to easily copy content from other machines on your network directly into the Plex library. You’ll have to do a small bit of extra work to get Plex to be able to access files copied into it from elsewhere, though.
In the TrueNAS web UI, go to Jails, select your Plex Jail, and click Shell.
Assuming your Plex libraries are located in the directory
/plex-content/, you can run the following command to give the Plex system user ownership of the files.
chown -R plex /plex-content
If you want to automate this, you can set up a cron job to do it automatically. From the same shell, run
crontab -e which will open a file containing your configured cron jobs. Add the following line, which will automatically execute the command every 5 minutes.
*/5 * * * * chown -R plex /plex-content >/dev/null 2>&1
Now, anything copied into the Plex library will automatically have ownership transferred to the Plex system user. If you’re confused by the syntax, so are most people. I used crontab-generator.org to generate the syntax for me.
Setting Up Nextcloud
While a TrueNAS plugin exists for Nextcloud, I could not get it working, and it seemed like many other users had the same experience, so I ended up just running it in a TrueNAS Virtual Machine running Ubuntu Server 20.04.1 LTS. It’s just as easy to set up this way, though, especially using Ubuntu Server 20.04.
First, download the ISO for Ubuntu Server 20.04.1 LTS and save it to your computer somewhere; we’ll be using it in a minute. Then, head to your TrueNAS web UI and go to the Virtual Machines tab, and click Add.
Select Linux for “Guest Operating System”, give it a name (like “nextcloud”), leave the other options as the defaults, and click Next.
Then, configure your VM’s virtual hardware. It doesn’t need to be too beefy, the configuration shown below should be enough for most average home users. If you’re running for an enterprise environment, you probably want to modify it a bit for performance. When you’re done, click Next.
On the next screen, you’ll create a virtual disk for the VM to use. You’ll select one of your storage pools, and allocate how much storage you want the VM to have access to, then click Next.
On the next screen, you can leave the default network configuration, then click Next. Now, we’ll upload our Ubuntu ISO to use as the installation media for the VM. Then click Next, and on the next screen, click Submit.
Then, to access the installer, select your newly created VM and open a new VNC terminal to it.
Follow the on-screen instructions from the Ubuntu installer. At the end, the installer will ask you if you want to use any of the featured Snap packages. Select the Nextcloud snap package, then wait for the installer to finish.
In the mean time, if you’re using a reverse proxy server, you can add your proxy NGINX configuration the same way we did for Plex, just changing the IP address to the IP address of your new VM and removing the port number. You’ll also need to configure this IP as a static route in your network router, just like we did for Plex.
Once Ubuntu is finished installing and rebooting on your VM, open a new VNC terminal; there are a couple of minor configuration tweaks we need to make to the Nextcloud configuration.
In order for Nextcloud to allow us to access it from our domain name, we need to tell Nextcloud to trust the domain name. Run
sudo vim /var/snap/nextcloud/current/nextcloud/config/config.php to edit the configuration file, and add your domain to the
Now, you should be able to access your Nextcloud server using your domain name. Since Nextcloud is sitting behind your reverse proxy server, we also need to make some other minor tweaks to
config.php in order to get authentication working for the iOS and Android Nextcloud apps. We just need to add the
trusted_proxies configuration to tell Nextcloud that the connection is going to be proxied by another server.
Now you should be able to log into the iOS and Android Nextcloud apps using your Nextcloud server URL (i.e. nextcloud.my-domain.com).
I originally tried out TrueNAS just because I wanted to stop using Google Drive and Google Calendar for privacy reasons, and Nextcloud doesn’t run on Windows, but I ended up loving the experience. TrueNAS made it incredibly easy to get my Plex Media Server and Nextcloud set up in no time, and I’m in full control of the data since it’s all running on a physical server in my house.
The verdict: I can highly recommend TrueNAS for anyone looking to set up a home lab server, especially if you’re new to network and server administration.