davide 8c56e2fc9f feat: add wg-init service and pin image to minor tag
Introduce a wg-init container (Alpine) that runs before wg-easy and:
- loads ip6_tables and ip6table_nat kernel modules (silently skipped if
  already built-in or unavailable), fixing startup on hosts that do not
  auto-load these modules (e.g. Raspberry Pi)
- sets chmod 700 on wg-data/ so private keys are protected from the
  moment the container writes them

wg-easy now depends on wg-init completing successfully, making the setup
portable across hardware without any manual host configuration.

Also pins the image tag from 15.2.2 to the minor tag (15) to receive
patch updates automatically while avoiding breaking changes across majors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 08:07:50 +02:00
2026-04-12 23:15:02 +02:00

WireGuard VPN con wg-easy (Docker)

Una configurazione Docker pronta all'uso per eseguire un server VPN WireGuard con interfaccia web wg-easy, ideale per Raspberry Pi o qualsiasi server Linux.


Prerequisiti

  • Docker e Docker Compose installati sul server
  • Una porta UDP aperta sul router/firewall (default: 51820)
  • Un indirizzo IP pubblico statico oppure un hostname DDNS (es. DuckDNS, No-IP)

Configurazione rapida

1. Clona il repository

git clone https://santantonio.sytes.net/davide/vpn.git
cd vpn

2. Crea il file .env

cp .env.example .env

L'unica variabile obbligatoria è TZ (già precompilata con Europe/Rome). Le porte possono essere lasciate ai valori di default.

Variabile Descrizione Default
TZ Fuso orario (formato IANA) Europe/Rome
WG_PORT Porta UDP WireGuard 51820
WG_UI_PORT Porta TCP interfaccia web 51821

Nota v15: host VPN, password e DNS si configurano dalla web UI al primo avvio.

3. Apri la porta sul router

Inoltra la porta UDP 51820 (o quella scelta in WG_PORT) verso l'IP locale del server.

4. Avvia il container

docker compose up -d

5. Completa il setup dalla web UI

http://IP_DEL_TUO_SERVER:51821

Al primo avvio appare un wizard che guida nella configurazione di password, hostname DDNS e DNS per i client. Dopo il setup puoi aggiungere client, scaricare configurazioni e generare QR code per dispositivi mobili.


Struttura del progetto

vpn/
├── docker-compose.yml   # Definizione del servizio
├── .env.example         # Template variabili (committato)
├── .env                 # Variabili locali (NON committato)
├── .gitignore
├── README.md
└── wg-data/             # Generato automaticamente dal container (NON committato)
    ├── wg0.conf         # Configurazione WireGuard
    └── wg0.json         # Stato interno wg-easy (peer, chiavi)

Aggiornare wg-easy

Esegui mensilmente per ricevere patch di sicurezza:

docker compose pull
docker compose up -d

Sicurezza

  • wg-data/ contiene chiavi crittografiche private. Non committarla mai su Git.
  • .env contiene variabili locali specifiche del server. Non committarlo.
  • Entrambi sono esclusi da .gitignore.
S
Description
Setup per wireguard VPN dockerizzato
Readme 51 KiB
Languages
Markdown 100%