Running a homeserver behind a cheap VPS edge server

I used to run a VPS that cost me about 80 € per month. Now, I have a much more cost-effective setup: a small edge server for about 4 € per month that acts as a gateway for a server running at my home.

Setup

The core of this setup is a WireGuard tunnel between my homeserver and the edge server. This allows me to expose services running on my homeserver to the internet through the edge server's public IP address.

1. Install WireGuard on Debian

First, you need to install WireGuard on both the edge server and the homeserver. If you're using Debian, it's pretty straightforward:

sudo apt update
sudo apt install wireguard

2. Generate Keys

Next, generate a private and public key for both servers.

On the edge server:

wg genkey | sudo tee /etc/wireguard/edge_private.key
sudo cat /etc/wireguard/edge_private.key | wg pubkey | sudo tee /etc/wireguard/edge_public.key

On the homeserver:

wg genkey | sudo tee /etc/wireguard/home_private.key
sudo cat /etc/wireguard/home_private.key | wg pubkey | sudo tee /etc/wireguard/home_public.key

3. Configure WireGuard

Now, you need to configure the WireGuard interfaces on both servers. You'll need the public keys from both servers for this step.

Edge server configuration (/etc/wireguard/wg0.conf):

[Interface]
Address = 10.0.0.1/24
PrivateKey = <content-of-edge_private.key>
ListenPort = 51820

[Peer]
PublicKey = <content-of-home_public.key>
AllowedIPs = 10.0.0.2/32

Homeserver configuration (/etc/wireguard/wg0.conf):

[Interface]
Address = 10.0.0.2/24
PrivateKey = <content-of-home_private.key>

[Peer]
PublicKey = <content-of-edge_public.key>
Endpoint = <edge-server-public-ip>:51820
AllowedIPs = 10.0.0.1/32
PersistentKeepalive = 25

4. Enable WireGuard at Boot

To make sure the WireGuard tunnel starts automatically when the servers boot, enable the wg-quick service:

sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0

Pitfalls

The setup was mostly smooth, but I did run into one issue. I had to change the MTU (Maximum Transmission Unit) on the WireGuard connection on my homeserver to avoid connection issues with some services. I added MTU = 1420 to the [Interface] section of my homeserver's wg0.conf.

Energy Costs

My homeserver consumes about 20 watts on average, with peaks up to 70 watts. Let's calculate the yearly energy costs.

Assuming an average consumption of 20 watts and an electricity price of 0.30 €/kWh:

20 W * 24 h/day * 365 days/year = 175,200 Wh = 175.2 kWh 175.2 kWh * 0.30 €/kWh = 52.56 € per year

To minimize these costs, I'm planning to install a balcony power plant. This should significantly reduce my electricity bill.

Extra: Service Monitoring

This setup is great for saving money, but let's be honest, it's less reliable than a full cloud-only VPS solution. That's why monitoring is crucial.

I use Uptime Kuma, which runs on my edge server, to monitor my important services. If a service goes down, I get an SMS alert via Twilio. This way, I can react quickly to any issues.

Recommendation

If you're looking for a cheap and reliable VPS for your edge server, I can recommend Hetzner Cloud.

When you sign up using this link, you'll get €20 in cloud credits for free.

The author of this blog post did not receive any of the mentioned devices from the manufacturer for free and is not in any other connection with the manufacturer. This post contains affiliate and referral links for which the author may receive a commission for sales or sign-ups.

Share this post: