Skip to content

Tag: homelab

Cleaner nginx proxy configs

I’ve been slowly teaching myself self-hosting things over the past few years. I’ve got a decent variety of things running at home. But I find it frustrating to keep track of their IPs and ports so I setup a reverve proxy which is a fancy term for one little linux container on my network directs you to everything else. Now I can hit plex.domain.tld, or wiki.domain.tld and get to where I want to go.

I had all of these setup with their own individual config files were very short. Most of them were little more than:

# A small thing running on a raspberry pi

server {
listen 80;
server_name pi.domain.tld

location / {
proxy_pass http://192.168.0.99:80;
}
}

I know there’s an easier way. And tonight I found a post that laid it all out and it clicked for me.

Timothy Quinn’s Using Nginx as a Reverse Proxy for Multiple Sites laid it all out and I realized all I needed to do was add all of my little config files to one big file. And I add a comment to the front of  each config to remind myself what it was and anything important to remember. This worked great for my Tiddlywiki, RSS reader, Calibre-web and Bookstack instance I have running.

His example is for sites with SSL enabled which I’m not going to move tonight. But I replicated this for all of my sites not running SSL. My next task is to move the SSL-enabled ones. But I run Nextcloud for myself and my wife so I need to take more time and make sure I do that right since it’s as close to a “production” thing that I self-host. So if it’s down, it affects more than just me.

Backups will save you

It’s true what they say. Backups are important!
 
Today was the perfect storm of why backups are important. Last night, I violated my own rule of working on projects after midnight. I thought it would be a good idea to update PHP on the server where my Nextcloud installation lives. The place where I keep and sync my files for work and I setup for my wife so she could stop paying for Dropbox.
 
I wanted to upgrade PHP so I could move to the newer versions of Nextcloud. Then, I decided to upgrade Nextcloud. So I updated PHP and Nextcloud itself. After midnight. A sure recipe for success!
 
Logging back into Nextcloud told me, This directory is unavailable, please check the logs or contact the administrator. Well, I am the administrator so that option’s out. I asked him. He’s clueless. So I went looking at the logs and they were full of errors I didn’t understand. Not enough to craft the search term that might lead to help. After a brief trip through github issues and forum posts, I gave up. I had to roll back the server to the last backup.
 
The latest one was from two nights ago. So I started the restore and went to sleep.
 
The next morning, I checked on Proxmox and after about 5 hours, the data restore completed. I took a deep breath and logged into the server.
 
No errors.
 
Files were all there.
 
Things looked good.
 
Until later that morning when my wife made sounds of distress, which I feared was my doing. Sure enough, there was a directory missing from her files. One she needed for work today. In about 30 minutes.
 
I had forgotten to mention what happened to her in the morning. She was mad. She was right.
 
I took my second deep breath of the day, asked for her laptop and the name of the folder and about where it was in her folders. (There are SO. MANY. FOLDERS.)
 
I opened Time Machine and hope the NAS downstairs had done its job. I’d had such a hard time getting the Mac mini on her desk remaining connected to the NAS to back itself up. I had setup oour laptops to backup on the same day. My laptop had not complained. So I was hopeful I my planning would pay off.
 
I was not. Time Machine did its job. I was able to locate and recover the directory and all its contents from a backup from yesterday evening.
 
Let my near-fatal errors be a lesson to you!
 
(I’m not sure my wife would have spared me and no jury would have convicted her.)
 
Backup your data.
 
For Proxmox, where I’m running Nextcloud and Plex and some other toys, it has an option to back itself up. Turn It On!
 
You know, that laptop you carry around? The one lucky enough to not have a drink spilled into it. The computer that occaional flies off desks and sofas, back it up.
 
On the Mac, it’s as easy and low tech as plugging in an external hard drive. Telling Time Machine to use that drive, and walking away. Plug that drive in as often as you like and let it handle the rest.
 
 
On any platform, you can use a service like Backblaze to send your data to the cloud. But please, whatever you do, learn from my mistakes. Whether it’s a stupid thing you do, or an accident you didn’t cause, you will lose data.
 
A backup wil save you.
 
And before you think you’re safe because you use Dropbox, Google Drive, or iCloud, I ask you. Do you sync those files? Sync is Not Backup. Replace Nextcloud in my story with any of the alternatives and you get to the same place. On the next sync, those files in the cloud are gone.
 
And for the server savvy who think you’re safe because your data is in a RAID, Raid is not backup!