You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/post/2025/05-29-traefik-load-balancer/index.mdx
+17-16Lines changed: 17 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,22 +22,23 @@ import TraefikLoadBalancerArchitectureImage from '../../../../content/post/2025/
22
22
23
23
## Introduction
24
24
25
-
This article is a continuation of [Expose home server with Rathole tunnel and Traefik](https://nemanjamitic.com/blog/2025-04-29-rathole-traefik-home-server#exposing-multiple-servers), which explains how to permanently host websites from hom by bypassing CGNAT. That setup works well for exposing a single home server (like a Raspberry Pi, server PC, or virtual machine), but it has a limitation: it requires one VPS (or at least one public network interface) per home server. This is because the Rathole server exclusively uses ports `80` and `443`.
25
+
This article is a continuation of [Expose home server with Rathole tunnel and Traefik](/blog/2025-04-29-rathole-traefik-home-server#exposing-multiple-servers), which explains how to permanently host websites from home by bypassing CGNAT. That setup works well for exposing a single home server (like a Raspberry Pi, server PC, or virtual machine), but it has a limitation: it requires one VPS (or at least one public network interface) per home server. This is because the Rathole server exclusively uses ports `80` and `443`.
26
26
27
-
But it doesn't have to be like this. We can reuse a single Rathole server for many tunnels and home servers, we just need a tool to load balance their traffic. As long as our VPS's network interface provides enough bandwidth for our websites and services.
27
+
But it doesn't have to be like this. We can reuse a single Rathole server for many tunnels and home servers, we just need a tool to load balance their traffic, as long as our VPS's network interface provides enough bandwidth for our websites and services.
28
28
29
29
This article explains how to achieve that using Traefik HTTP and TCP routers.
30
30
31
+
31
32
## Prerequisites
32
33
33
-
- A working Rathole tunnel setup from the previous article (including a VPS and domain name)
34
-
- More than one home server (Raspberry Pi, server PC, virtual machine, LXC container)
34
+
- A working Rathole tunnel setup from the previous article (including a VPS and a domain name)
35
+
- More than one home server (Raspberry Pi, server PC, virtual machine, or LXC container)
35
36
36
37
## Architecture overview
37
38
38
39
### The problem
39
40
40
-
The main problem here is that we can't bind more than one port to ports `80` and `443` respectively. Only one service can listen at one port at same time. So something like this doesn't exist:
41
+
The main problem here is that we can't bind more than one port to ports `80` and `443`, respectively. Only one service can listen on a given port at the same time. So something like this doesn't exist:
Neither operating system nor Docker provide load balancing functionality out of the box, we need to handle it ourselves.
60
+
Neither the operating system nor Docker provides load balancing functionality out of the box, we need to handle it ourselves.
60
61
61
62
### The solution
62
63
63
-
We need to introduce a tool for load balancing traffic between tunnels, we will use Traefik since we already use it with Rathole client.
64
+
We need to introduce a tool for load balancing traffic between tunnels. We will use Traefik, since we already use it with the Rathole client.
64
65
65
-
For each home server we need 2 tunnels, one for HTTP and another for HTTPS traffic:
66
+
For each home server, we need 2 tunnels: one for HTTP and another for HTTPS traffic:
66
67
67
-
1. Tunnel for HTTP traffic will use Traefik HTTP router as usual.
68
-
2. Tunnel for HTTPS traffic is a bit more interesting and challenging. For it, we will use Traefik TCP router running in the passthrough mode since we don't want to terminate HTTPS traffic on the VPS but to delegate resolving certificates to the existing Traefik running on the client side to keep the existing setup and architecture.
68
+
1. The tunnel for HTTP traffic will use the Traefik HTTP router as usual.
69
+
2. The tunnel for HTTPS traffic is a bit more interesting and challenging. For it, we will use the Traefik TCP router running in passthrough mode, since we don't want to terminate HTTPS traffic on the VPS. Instead, we want to delegate certificate resolution to the existing Traefik instance running on the client side to preserve the current setup and architecture.
I already wrote about the advantage of resolving SSL certificates locally on home server in the [Architecture overview](https://nmc-docker.pi.nemanjamitic.com/blog/2025-04-29-rathole-traefik-home-server#architecture-overview) section of the previous article but here is a quick recap again:
75
+
I already wrote about the advantage of resolving SSL certificates locally on the home server in the [Architecture overview](/blog/2025-04-29-rathole-traefik-home-server#architecture-overview) section of the previous article, but here is a quick recap:
75
76
76
-
1. Home server contains its entire configuration
77
-
2. Home server is tunnelagnostic and reusable
78
-
3. No coupling between tunnel server and client, no need to maintain state/version
79
-
4. Decoupled debugging
80
-
5. Improved security, additional encryption layer further down the tunnel
77
+
1. The home server contains its entire configuration
78
+
2. The home server is tunnel-agnostic and reusable
79
+
3. No coupling between the tunnel server and client, no need to maintain state or version
80
+
4. Decoupled debugging
81
+
5. Improved security—an additional encryption layer further down the tunnel
0 commit comments