To use caddy as a reverse proxy for a caddy webserver
The VPS caddy is going to handle SSL. If you attempt to have the LAN server also do SSL you are fucked, only one can. Well, I’m sure you could double SSL with an insane amount of work for 0 benefit, but why?
VPS /etc/caddy/Caddyfile
bullshark.win {
reverse_proxy 10.0.1.2:80 {
transport http
}
}
LAN / webserver /etc/caddy/Caddyfile
{
auto_https off
}
:80 {
root * /path/to/site/files
file_server
}
Tunneling and subnetting freakiness
With the configuration:
| Gitea caddy | Web Caddy | VPS |
|---|---|---|
| 10.0.0.2 | 10.0.0.3 | 10.0.01 |
It would NOT work. One would work, then I get the other up and they both come down.
With the configuration:
| Machine | Gitea caddy | Web Caddy | VPS gitea | VPS web |
|---|---|---|---|---|
| IP | 10.0.0.2/24 | 10.0.1.2/24 | 10.0.01 | 10.0.1.1 |
| Port | 51900 | 51900 | 51905 | 51905 |
It works fine.
Make sure you apply ufw allow 51905/udp if you add another port
I’m unsure if the fix was them being on different subnets, server IPs, server interfaces, or ports. However, 2 separate tunnels applies all solutions.
This took wayyyyyy longer than it should have. Also ufwed myself out of 22 and had to VNC into my server. Awesome.