Despite my love for virtualizing operating systems and containerizing services, I always feel a little terrified of messing around with network utilities. After all, I grew up seeing the “It’s always DNS” meme, and have had many projects thwarted by incorrectly set up network files. And as is customary for home labbers, those were errors that I only diagnosed after bringing my entire home’s Internet down.

Take reverse proxies, for instance. I tend to use them rather sparingly, and the last time I used Nginx was for a college project where I had to map some domain names my group had bought for a service hosted on a VPS. However, after a little chat with our technical expert, Adam Conway, I figured I could try using custom domain names for my home lab. Now that I’ve done so, reverse proxies and local DNS records are surprisingly easy to configure – and here’s how I use them in tandem with my self-hosted repertoire.

A general overview of the setup

Pi-hole and Nginx are a killer combo

Our story begins with Nginx, a web server utility that I primarily use as a reverse proxy. If you’re unfamiliar with the term, you can think of reverse proxies as intermediary agents that accept requests from client systems and route them to a pre-configured endpoint. In this case, I wanted Nginx to accept requests for specific domain names and point the client devices to the right service. I could’ve gone with Caddy, since it can provision TLS certificates automatically. However, I’m more familiar with Nginx's (or specifically, the Nginx Proxy Manager's) intuitive web UI, where I can add the domain names using a few buttons, as opposed to making multiple config file tweaks inside a Caddy service.

Let’s say I’ve got a SilverBullet container running at the IPv4 address of 192.168.1.84:3000. If I wanted to map the name silverbullet.ayushlab.local to this container, I’d create a record for it on Nginx. Sounds simple, right?

Well, there’s a bit more nuance to the setup. You see, unlike the time I used Nginx for the university project, the domain name silverbullet.ayushlab.local doesn’t actually exist (at least, not as of writing this article). So, attempting to open it would cause a DNS error, as there are no records for the link out there. I could try buying a domain and using it for my self-hosted suite, but my empty wallet would love to differ.

That’s where local DNS records come into the picture. Rather than shelling out some money to a domain registrar, I could map custom domain names to my home lab utilities and use them in tandem with Nginx to access my self-hosted stack from anywhere. Going with the example from earlier, I’d have to create a local DNS record for silverbullet.ayushlab.local. But rather than mapping it to the SilverBullet container’s IP address, I’d have to set it to the IP address of my Nginx utility inside the DNS record. Although there are plenty of other tools that could help me create local DNS records, I use Pi-hole for the job, as I’m already familiar with the tool.

Configuring the services

Assigning the domain names in Nginx

With the theory part done and dusted, it’s time to go over the actual setup process. First, I entered the bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/nginxproxymanager.sh)" command inside the Shell tab of my Proxmox node to deploy Nginx. I went with the default options, and agreed to install the add-on utilities. Once the Proxmox VE Helper-Script had worked its magic, I used the hyperlink to access the Nginx web interface. After entering admin@example.com and changeme as the credentials, I changed the default Email and password before logging in with them.

Inside the Nginx UI, I headed to the Hosts tab and pressed the Add Proxy Host button. I set silverbullet.ayushlab.local as the Domain name, 192.168.1.84 as the Forward Hostname/IP, and 3000 as the Forward Port. Since it’s an HTTP service, I didn’t have to deal with SSL certifications yet. But if I did, Nginx includes an option to request a new SSL certificate from Let’s Encrypt inside the SSL tab.

Setting up local DNS records in Pi-hole

With the domain name mapped to the right IP address, all that’s left is creating a local DNS record. Pi-hole includes a Local DNS Records tab, and that’s where I had to enter the custom domain name for each service, followed by the IPv4 URL of my Nginx server. For Silverbullet, I entered silverbullet.ayushlab.local as the Domain, typed 192.168.1.240 as the IP, and hit the Plus button to add the new local DNS record.

And voilà! Searching for silverbullet.ayushlab.local revealed my SilverBullet container in all its minimalist glory. I quickly started adding the rest of the services, and while I still need to generate some TLS certificates for my HTTPS tools, this simple yet reliable setup serves my HTTP utilities really well.