45 lines
1.4 KiB
Markdown
45 lines
1.4 KiB
Markdown
# Sicurezza
|
|
|
|
## Impostazioni consigliate
|
|
```ini
|
|
[service]
|
|
DISABLE_REGISTRATION = true ; server personale
|
|
REQUIRE_SIGNIN_VIEW = true ; opzionale: tutto privato
|
|
[session]
|
|
COOKIE_SECURE = true
|
|
[security]
|
|
INSTALL_LOCK = true
|
|
DISABLE_GIT_HOOKS = true
|
|
```
|
|
- Esporre fuori solo 80, 443, 2222; 3000 resta su 127.0.0.1.
|
|
- Backup di `app.ini` (SECRET_KEY/INTERNAL_TOKEN) separato e protetto.
|
|
- Aggiornare regolarmente l'immagine (vedi [backup-restore.md](backup-restore.md)).
|
|
- Preferire chiavi ED25519; abilitare 2FA per gli admin.
|
|
|
|
## Fail2ban (sull'host)
|
|
1. Log su file in `app.ini`:
|
|
```ini
|
|
[log]
|
|
MODE = console, file
|
|
LEVEL = Info
|
|
```
|
|
2. `/etc/fail2ban/filter.d/gitea.local`:
|
|
```ini
|
|
[Definition]
|
|
failregex = .*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>
|
|
ignoreregex =
|
|
```
|
|
3. `/etc/fail2ban/jail.d/gitea.local` (path del log: `<repo>/gitea-data/gitea/log/gitea.log`):
|
|
```ini
|
|
[gitea]
|
|
enabled = true
|
|
filter = gitea
|
|
logpath = /home/davide3011/gitea/gitea/gitea-data/gitea/log/gitea.log
|
|
maxretry = 10
|
|
findtime = 3600
|
|
bantime = 900
|
|
action = iptables-allports
|
|
```
|
|
4. Con Docker aggiungere un jail con `action = iptables-allports[chain="FORWARD"]`.
|
|
5. Per vedere l'IP reale impostare `REVERSE_PROXY_LIMIT = 1` e `REVERSE_PROXY_TRUSTED_PROXIES` con la subnet docker (172.16.0.0/12 di norma). Verificare i path/permessi del log prima di fidarsi.
|