42 lines
1.4 KiB
Markdown
42 lines
1.4 KiB
Markdown
# Reverse proxy Caddy
|
|
|
|
`Caddyfile` attuale:
|
|
```
|
|
your-domain.com {
|
|
reverse_proxy gitea:3000
|
|
}
|
|
```
|
|
Caddy gestisce da solo certificato Let's Encrypt, rinnovi, redirect HTTP→HTTPS e WebSocket (`/-/ws`, aggiornamenti in tempo reale) con `reverse_proxy`. Passa `Host` e `X-Forwarded-Proto` correttamente.
|
|
|
|
## Requisiti in Gitea
|
|
```ini
|
|
[server]
|
|
ROOT_URL = https://your-domain.com/
|
|
DOMAIN = your-domain.com
|
|
[security]
|
|
REVERSE_PROXY_LIMIT = 1
|
|
REVERSE_PROXY_TRUSTED_PROXIES = 172.16.0.0/12 ; subnet rete docker compose (verificare)
|
|
```
|
|
Senza trusted proxies corretto Gitea (e fail2ban/log) vede l'IP del container Caddy invece del client.
|
|
|
|
## Sub-path (sconsigliato)
|
|
```
|
|
git.example.com {
|
|
route /git/* {
|
|
uri strip_prefix /git
|
|
reverse_proxy gitea:3000
|
|
}
|
|
}
|
|
```
|
|
`ROOT_URL = https://git.example.com/git/`. Il proxy non deve decodificare `%2F`. Il registry container richiede `/v2` alla radice del dominio.
|
|
|
|
## Comandi
|
|
```bash
|
|
docker compose exec caddy caddy reload --config /etc/caddy/Caddyfile
|
|
docker compose logs caddy
|
|
```
|
|
Il certificato non viene emesso se 80/443 non sono raggiungibili o il DNS non punta all'IP pubblico. Per test senza rate limit, usare in `Caddyfile` la direttiva globale `{ acme_ca https://acme-staging-v02.api.letsencrypt.org/directory }`.
|
|
|
|
## Limiti upload
|
|
Caddy non limita il body di default; i limiti sono in Gitea (`[attachment] MAX_SIZE`, `[repository.upload]`, `[packages] LIMIT_SIZE_*`).
|