Add tech_docs/networking/caddy.md

This commit is contained in:
2025-09-14 22:10:44 +00:00
parent 418a4953fc
commit 501a0074fb

View File

@@ -0,0 +1,51 @@
Exactly — keep **one** central Caddy **outside** Docker (systemd) and proxy to **whatever** runs inside containers, VMs, or localhost.
Thats the **single source of truth** you want.
--------------------------------------------------
1. Central Caddyfile (systemd) **one file** rules them all
----------------------------------------------------
```bash
sudo nano /etc/caddy/Caddyfile
```
Content (add more blocks as you spin up services):
```
# Git service inside Docker
git.crazystorm-andromeda.duckdns.org {
reverse_proxy localhost:3000 # Docker published port
encode gzip
header -Server
}
# Future service just add another block
# next.crazystorm-andromeda.duckdns.org {
# reverse_proxy localhost:4000
# }
```
--------------------------------------------------
2. Reload after any edit
----------------------------------------------------
```bash
sudo systemctl reload caddy
```
--------------------------------------------------
3. Benefits you keep
----------------------------------------------------
- **One** Lets Encrypt account, **one** cert cache, **one** log stream
- **No** extra Caddy container to babysit
- **Any** backend (Docker, native, remote IP) just becomes another `reverse_proxy` line
- **Survives** Docker Compose restarts; systemd starts before Docker
--------------------------------------------------
4. House-keeping
----------------------------------------------------
```bash
# validate syntax
caddy validate --config /etc/caddy/Caddyfile
# live reload
sudo systemctl reload caddy
```
Thats the **central, primitive, single-file** setup — add a block, reload, done.