Replace from-scratch rewrite with real ngoduykhanh/wireguard-ui fork
The from-scratch Go rewrite had unresolved bugs (missing go.sum, UI 404s, path issues) from being built without a working local Go toolchain to verify against. Switching strategy: use the actual upstream wireguard-ui codebase (proven, battle-tested single-server manager) as the base, and extend it for multi-server support instead of re-deriving everything from zero. Kept our own installers (bootstrap.sh, update.sh, scripts/install.sh, scripts/proxmox-install.sh) - these still apply, just need updating to build/install the upstream module layout instead of the old cmd/wireguard-ui-multi structure. Module path intentionally left as upstream's own (github.com/ngoduykhanh/wireguard-ui) for now to avoid touching every internal import; revisit if this needs to be fully rebranded. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
6eeea65ede
commit
867dc7740a
@@ -1,280 +1,246 @@
|
||||
# wireguard-ui-multi
|
||||

|
||||
|
||||
Native Multi-Server-Verwaltungsoberfläche für WireGuard — **ohne Docker**.
|
||||
Im Gegensatz zum ursprünglichen `wireguard-ui`, das genau eine WireGuard-Instanz
|
||||
verwaltet, kann `wireguard-ui-multi` mehrere unabhängige WireGuard-Interfaces
|
||||
gleichzeitig verwalten (z. B. `wg-home`, `wg-rz`, `wg-winter`), jedes mit
|
||||
eigenem Port, eigenem Adressbereich, eigenen Peers und eigenem Status.
|
||||
# wireguard-ui
|
||||
|
||||
Zielumgebungen: Debian/Ubuntu, Proxmox LXC Container, generisches Linux mit
|
||||
systemd. Betrieb als natives Go-Binary.
|
||||
A web user interface to manage your WireGuard setup.
|
||||
|
||||
## Features
|
||||
|
||||
- **Multi-Server-Verwaltung**: beliebig viele WireGuard-Server, jeder mit
|
||||
eigenem Interface-Namen, Port, Private/Public Key, Adressbereich, DNS, MTU
|
||||
und Enabled/Disabled-Status (Tabelle `servers` in SQLite).
|
||||
- **Peer-Verwaltung pro Server**: Peers gehören zu genau einem Server
|
||||
(Fremdschlüssel `server_id`), inklusive Name, E-Mail, Public/Private/
|
||||
Preshared Key, Allowed IPs, Endpoint, Persistent Keepalive, Enabled-Status
|
||||
und optionalem Ablaufdatum (`expires_at`).
|
||||
- **Automatische Config-Erzeugung**: Server-Configs werden nach
|
||||
`/etc/wireguard/<interface>.conf` im Standard-`wg-quick`-Format geschrieben.
|
||||
- **Service-Steuerung**: Start/Stop/Reload je Interface über `wg-quick up`,
|
||||
`wg-quick down` und `wg syncconf` (Hot-Reload ohne Verbindungsabbruch),
|
||||
Status-Abfrage über `wg show`.
|
||||
- **QR-Code & Config-Download**: Peer-Konfiguration kann als `.conf`-Datei
|
||||
heruntergeladen oder als QR-Code (PNG) angezeigt werden — Private Keys
|
||||
verlassen den Server nur in dieser generierten Peer-Config, nie über die
|
||||
UI/JSON-API.
|
||||
- **REST-API** für Server- und Peer-Verwaltung (siehe unten) plus
|
||||
Web-Dashboard.
|
||||
- **Firewall-Vorbereitung**: optionale Lifecycle-Hook-Skripte
|
||||
(`server-start`, `server-stop`, `peer-add`, `peer-remove`) in
|
||||
`/etc/wireguard-manager/hooks/` sowie ein Generator für einen
|
||||
Vorschlags-nftables-Ruleset pro Server (Port freigeben, Forwarding
|
||||
Tunnel ↔ LAN-Interface).
|
||||
- **Audit Log**: Tabelle `audit_log` protokolliert Aktionen mit Akteur,
|
||||
Aktion, Ziel und Detail.
|
||||
- **Sitzungsbasierte Authentifizierung** mit CSRF-Schutz: jede mutierende
|
||||
Anfrage (POST/PUT/DELETE) benötigt einen gültigen Session-Cookie plus
|
||||
den Header `X-CSRF-Token`.
|
||||
- Optional HTTPS über `--tls-cert` / `--tls-key`.
|
||||
- Friendly UI
|
||||
- Authentication
|
||||
- Manage extra client information (name, email, etc.)
|
||||
- Retrieve client config using QR code / file / email / Telegram
|
||||
|
||||
## Installation
|
||||

|
||||
|
||||
### Hardware-Anforderungen
|
||||
## Run WireGuard-UI
|
||||
|
||||
Betrieb selbst ist sehr genügsam (kleines Go-Binary + SQLite, kein Docker/JVM):
|
||||
> ⚠️The default username and password are `admin`. Please change it to secure your setup.
|
||||
|
||||
- **Betrieb:** 1 vCPU, 128-256 MB RAM reichen locker
|
||||
- **Build aus Quellcode:** mind. **1 GB RAM** während `go build` — das
|
||||
`modernc.org/sqlite`-Package (reines Go, kein cgo, aber sehr großzügiger
|
||||
generierter Code) sprengt den `go`-Compiler bei 512 MB LXC-RAM
|
||||
(`signal: killed`, OOM-Killer). Bei 1 GB lief der Build durch.
|
||||
- Nach dem Build kann der Container/Server wieder auf 256-512 MB reduziert
|
||||
werden, falls Ressourcen knapp sind.
|
||||
- Alternative ohne Build-RAM-Bedarf: fertiges Release-Binary nutzen, sobald
|
||||
eine Release-Pipeline existiert (`bootstrap.sh` versucht das automatisch
|
||||
zuerst und fällt nur bei Fehlschlag auf den Source-Build zurück).
|
||||
### Using binary file
|
||||
|
||||
### Schnellinstallation (Einzeiler)
|
||||
Download the binary file from the release page and run it directly on the host machine
|
||||
|
||||
Auf einem frischen Debian/Ubuntu-Host (als root), lädt und installiert alles
|
||||
in einem Schritt (Abhängigkeiten, Go-Toolchain falls nötig, Quellcode, Build,
|
||||
`install.sh`):
|
||||
```
|
||||
./wireguard-ui
|
||||
```
|
||||
|
||||
### Using docker compose
|
||||
|
||||
The [examples/docker-compose](examples/docker-compose) folder contains example docker-compose files.
|
||||
Choose the example which fits you the most, adjust the configuration for your needs, then run it like below:
|
||||
|
||||
```
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Description | Default |
|
||||
|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------|
|
||||
| `BASE_PATH` | Set this variable if you run wireguard-ui under a subpath of your reverse proxy virtual host (e.g. /wireguard) | N/A |
|
||||
| `BIND_ADDRESS` | The addresses that can access to the web interface and the port, use unix:///abspath/to/file.socket for unix domain socket. | 0.0.0.0:80 |
|
||||
| `SESSION_SECRET` | The secret key used to encrypt the session cookies. Set this to a random value | N/A |
|
||||
| `SESSION_SECRET_FILE` | Optional filepath for the secret key used to encrypt the session cookies. Leave `SESSION_SECRET` blank to take effect | N/A |
|
||||
| `SESSION_MAX_DURATION` | Max time in days a remembered session is refreshed and valid. Non-refreshed session is valid for 7 days max, regardless of this setting. | 90 |
|
||||
| `SUBNET_RANGES` | The list of address subdivision ranges. Format: `SR Name:10.0.1.0/24; SR2:10.0.2.0/24,10.0.3.0/24` Each CIDR must be inside one of the server interfaces. | N/A |
|
||||
| `WGUI_USERNAME` | The username for the login page. Used for db initialization only | `admin` |
|
||||
| `WGUI_PASSWORD` | The password for the user on the login page. Will be hashed automatically. Used for db initialization only | `admin` |
|
||||
| `WGUI_PASSWORD_FILE` | Optional filepath for the user login password. Will be hashed automatically. Used for db initialization only. Leave `WGUI_PASSWORD` blank to take effect | N/A |
|
||||
| `WGUI_PASSWORD_HASH` | The password hash for the user on the login page. (alternative to `WGUI_PASSWORD`). Used for db initialization only | N/A |
|
||||
| `WGUI_PASSWORD_HASH_FILE` | Optional filepath for the user login password hash. (alternative to `WGUI_PASSWORD_FILE`). Used for db initialization only. Leave `WGUI_PASSWORD_HASH` blank to take effect | N/A |
|
||||
| `WGUI_ENDPOINT_ADDRESS` | The default endpoint address used in global settings where clients should connect to. The endpoint can contain a port as well, useful when you are listening internally on the `WGUI_SERVER_LISTEN_PORT` port, but you forward on another port (ex 9000). Ex: myvpn.dyndns.com:9000 | Resolved to your public ip address |
|
||||
| `WGUI_FAVICON_FILE_PATH` | The file path used as website favicon | Embedded WireGuard logo |
|
||||
| `WGUI_DNS` | The default DNS servers (comma-separated-list) used in the global settings | `1.1.1.1` |
|
||||
| `WGUI_MTU` | The default MTU used in global settings | `1450` |
|
||||
| `WGUI_PERSISTENT_KEEPALIVE` | The default persistent keepalive for WireGuard in global settings | `15` |
|
||||
| `WGUI_FIREWALL_MARK` | The default WireGuard firewall mark | `0xca6c` (51820) |
|
||||
| `WGUI_TABLE` | The default WireGuard table value settings | `auto` |
|
||||
| `WGUI_CONFIG_FILE_PATH` | The default WireGuard config file path used in global settings | `/etc/wireguard/wg0.conf` |
|
||||
| `WGUI_LOG_LEVEL` | The default log level. Possible values: `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` | `INFO` |
|
||||
| `WG_CONF_TEMPLATE` | The custom `wg.conf` config file template. Please refer to our [default template](https://github.com/ngoduykhanh/wireguard-ui/blob/master/templates/wg.conf) | N/A |
|
||||
| `EMAIL_FROM_ADDRESS` | The sender email address | N/A |
|
||||
| `EMAIL_FROM_NAME` | The sender name | `WireGuard UI` |
|
||||
| `SENDGRID_API_KEY` | The SendGrid api key | N/A |
|
||||
| `SENDGRID_API_KEY_FILE` | Optional filepath for the SendGrid api key. Leave `SENDGRID_API_KEY` blank to take effect | N/A |
|
||||
| `SMTP_HOSTNAME` | The SMTP IP address or hostname | `127.0.0.1` |
|
||||
| `SMTP_PORT` | The SMTP port | `25` |
|
||||
| `SMTP_USERNAME` | The SMTP username | N/A |
|
||||
| `SMTP_PASSWORD` | The SMTP user password | N/A |
|
||||
| `SMTP_PASSWORD_FILE` | Optional filepath for the SMTP user password. Leave `SMTP_PASSWORD` blank to take effect | N/A |
|
||||
| `SMTP_AUTH_TYPE` | The SMTP authentication type. Possible values: `PLAIN`, `LOGIN`, `NONE` | `NONE` |
|
||||
| `SMTP_ENCRYPTION` | The encryption method. Possible values: `NONE`, `SSL`, `SSLTLS`, `TLS`, `STARTTLS` | `STARTTLS` |
|
||||
| `SMTP_HELO` | Hostname to use for the HELO message. smtp-relay.gmail.com needs this set to anything but `localhost` | `localhost` |
|
||||
| `TELEGRAM_TOKEN` | Telegram bot token for distributing configs to clients | N/A |
|
||||
| `TELEGRAM_ALLOW_CONF_REQUEST` | Allow users to get configs from the bot by sending a message | `false` |
|
||||
| `TELEGRAM_FLOOD_WAIT` | Time in minutes before the next conf request is processed | `60` |
|
||||
|
||||
### Defaults for server configuration
|
||||
|
||||
These environment variables are used to control the default server settings used when initializing the database.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|-----------------------------------|-----------------------------------------------------------------------------------------------|-----------------|
|
||||
| `WGUI_SERVER_INTERFACE_ADDRESSES` | The default interface addresses (comma-separated-list) for the WireGuard server configuration | `10.252.1.0/24` |
|
||||
| `WGUI_SERVER_LISTEN_PORT` | The default server listen port | `51820` |
|
||||
| `WGUI_SERVER_POST_UP_SCRIPT` | The default server post-up script | N/A |
|
||||
| `WGUI_SERVER_POST_DOWN_SCRIPT` | The default server post-down script | N/A |
|
||||
|
||||
### Defaults for new clients
|
||||
|
||||
These environment variables are used to set the defaults used in `New Client` dialog.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|---------------------------------------------|-------------------------------------------------------------------------------------------------|-------------|
|
||||
| `WGUI_DEFAULT_CLIENT_ALLOWED_IPS` | Comma-separated-list of CIDRs for the `Allowed IPs` field. (default ) | `0.0.0.0/0` |
|
||||
| `WGUI_DEFAULT_CLIENT_EXTRA_ALLOWED_IPS` | Comma-separated-list of CIDRs for the `Extra Allowed IPs` field. (default empty) | N/A |
|
||||
| `WGUI_DEFAULT_CLIENT_USE_SERVER_DNS` | Boolean value [`0`, `f`, `F`, `false`, `False`, `FALSE`, `1`, `t`, `T`, `true`, `True`, `TRUE`] | `true` |
|
||||
| `WGUI_DEFAULT_CLIENT_ENABLE_AFTER_CREATION` | Boolean value [`0`, `f`, `F`, `false`, `False`, `FALSE`, `1`, `t`, `T`, `true`, `True`, `TRUE`] | `true` |
|
||||
|
||||
### Docker only
|
||||
|
||||
These environment variables only apply to the docker container.
|
||||
|
||||
| Variable | Description | Default |
|
||||
|-----------------------|---------------------------------------------------------------|---------|
|
||||
| `WGUI_MANAGE_START` | Start/stop WireGuard when the container is started/stopped | `false` |
|
||||
| `WGUI_MANAGE_RESTART` | Auto restart WireGuard when we Apply Config changes in the UI | `false` |
|
||||
|
||||
## Auto restart WireGuard daemon
|
||||
|
||||
WireGuard-UI only takes care of configuration generation. You can use systemd to watch for the changes and restart the
|
||||
service. Following is an example:
|
||||
|
||||
### Using systemd
|
||||
|
||||
Create `/etc/systemd/system/wgui.service`
|
||||
|
||||
```bash
|
||||
curl -fsSL https://gitea.perlbach24.de/scripte/wireguard-ui-multi/raw/branch/main/bootstrap.sh | bash
|
||||
cd /etc/systemd/system/
|
||||
cat << EOF > wgui.service
|
||||
[Unit]
|
||||
Description=Restart WireGuard
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/bin/systemctl restart wg-quick@wg0.service
|
||||
|
||||
[Install]
|
||||
RequiredBy=wgui.path
|
||||
EOF
|
||||
```
|
||||
|
||||
Danach nur noch:
|
||||
Create `/etc/systemd/system/wgui.path`
|
||||
|
||||
```bash
|
||||
sudo systemctl enable --now wireguard-ui-multi.service
|
||||
cd /etc/systemd/system/
|
||||
cat << EOF > wgui.path
|
||||
[Unit]
|
||||
Description=Watch /etc/wireguard/wg0.conf for changes
|
||||
|
||||
[Path]
|
||||
PathModified=/etc/wireguard/wg0.conf
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
```
|
||||
|
||||
Der Quellcode bleibt unter `/opt/wireguard-ui-multi-src` liegen; erneutes
|
||||
Ausführen des Einzeilers aktualisiert die Installation.
|
||||
Apply it
|
||||
|
||||
### Update
|
||||
|
||||
Für ein gezieltes Update (holt neuesten Code, baut neu, installiert neu und
|
||||
startet den Dienst neu):
|
||||
|
||||
```bash
|
||||
cd /opt/wireguard-ui-multi-src
|
||||
sudo ./update.sh
|
||||
```sh
|
||||
systemctl enable wgui.{path,service}
|
||||
systemctl start wgui.{path,service}
|
||||
```
|
||||
|
||||
### Manuelle Installation
|
||||
### Using openrc
|
||||
|
||||
#### 1. Aus dem Quellcode bauen
|
||||
Create `/usr/local/bin/wgui` file and make it executable
|
||||
|
||||
```bash
|
||||
go build -o wireguard-ui-multi ./cmd/wireguard-ui-multi
|
||||
```sh
|
||||
cd /usr/local/bin/
|
||||
cat << EOF > wgui
|
||||
#!/bin/sh
|
||||
wg-quick down wg0
|
||||
wg-quick up wg0
|
||||
EOF
|
||||
chmod +x wgui
|
||||
```
|
||||
|
||||
#### 2. Installationsskript ausführen (als root)
|
||||
Create `/etc/init.d/wgui` file and make it executable
|
||||
|
||||
```bash
|
||||
sudo ./scripts/install.sh
|
||||
```sh
|
||||
cd /etc/init.d/
|
||||
cat << EOF > wgui
|
||||
#!/sbin/openrc-run
|
||||
|
||||
command=/sbin/inotifyd
|
||||
command_args="/usr/local/bin/wgui /etc/wireguard/wg0.conf:w"
|
||||
pidfile=/run/${RC_SVCNAME}.pid
|
||||
command_background=yes
|
||||
EOF
|
||||
chmod +x wgui
|
||||
```
|
||||
|
||||
Das Skript ist idempotent und:
|
||||
Apply it
|
||||
|
||||
- kopiert die Binary nach `/usr/local/bin/wireguard-ui-multi`
|
||||
- legt `/etc/wireguard-ui-multi`, `/var/lib/wireguard-ui-multi` und
|
||||
`/etc/wireguard-manager/hooks` an
|
||||
- installiert die systemd-Unit nach
|
||||
`/etc/systemd/system/wireguard-ui-multi.service`
|
||||
- setzt `chmod 0700` auf das Datenverzeichnis (dort liegt die SQLite-DB mit
|
||||
Passwort-Hashes)
|
||||
|
||||
**Wichtig:** Das Skript startet den Dienst nicht automatisch. Danach manuell
|
||||
aktivieren:
|
||||
|
||||
```bash
|
||||
sudo systemctl enable --now wireguard-ui-multi.service
|
||||
sudo systemctl status wireguard-ui-multi.service
|
||||
sudo journalctl -u wireguard-ui-multi.service -f
|
||||
```sh
|
||||
rc-service wgui start
|
||||
rc-update add wgui default
|
||||
```
|
||||
|
||||
## Konfiguration
|
||||
### Using Docker
|
||||
|
||||
Die Anwendung wird über Kommandozeilen-Flags konfiguriert (siehe
|
||||
`cmd/wireguard-ui-multi/main.go`):
|
||||
Set `WGUI_MANAGE_RESTART=true` to manage Wireguard interface restarts.
|
||||
Using `WGUI_MANAGE_START=true` can also replace the function of `wg-quick@wg0` service, to start Wireguard at boot, by
|
||||
running the container with `restart: unless-stopped`. These settings can also pick up changes to Wireguard Config File
|
||||
Path, after restarting the container. Please make sure you have `--cap-add=NET_ADMIN` in your container config to make
|
||||
this feature work.
|
||||
|
||||
| Flag | Default | Bedeutung |
|
||||
|----------------|-------------------------------------------------------|-------------------------------------------------------|
|
||||
| `--listen` | `:8443` | Listen-Adresse des Webservers |
|
||||
| `--db` | `/var/lib/wireguard-ui-multi/wireguard-ui-multi.db` | Pfad zur SQLite-Datenbankdatei |
|
||||
| `--config-dir` | `/etc/wireguard` | Zielverzeichnis für generierte `wg-quick`-Configs |
|
||||
| `--hooks-dir` | `/etc/wireguard-manager/hooks` | Verzeichnis mit optionalen Hook-Skripten |
|
||||
| `--lan-iface` | `eth0` | LAN-Interface für die vorgeschlagenen nftables-Forward-Regeln |
|
||||
| `--tls-cert` | (leer) | Pfad zum TLS-Zertifikat (aktiviert HTTPS zusammen mit `--tls-key`) |
|
||||
| `--tls-key` | (leer) | Pfad zum TLS-Private-Key |
|
||||
## Build
|
||||
|
||||
Die in `systemd/wireguard-ui-multi.service` hinterlegte `ExecStart`-Zeile
|
||||
setzt `--db`, `--config-dir` und `--hooks-dir` bereits passend zur
|
||||
Installationsstruktur.
|
||||
### Build docker image
|
||||
|
||||
### Erststart / Admin-Passwort
|
||||
Go to the project root directory and run the following command:
|
||||
|
||||
Beim allerersten Start (leere `users`-Tabelle) wird automatisch ein
|
||||
`admin`-Benutzer mit einem zufällig erzeugten 32-stelligen Hex-Passwort
|
||||
angelegt. Das Klartext-Passwort wird **genau einmal** auf `stderr`
|
||||
ausgegeben (z. B. sichtbar via `journalctl -u wireguard-ui-multi.service`)
|
||||
und danach nur noch als bcrypt-Hash in der Datenbank gespeichert. Nach dem
|
||||
ersten Login sollte das Passwort umgehend geändert werden.
|
||||
|
||||
## LXC / Proxmox Hinweise
|
||||
|
||||
WireGuard benötigt Zugriff auf das `wireguard`-Kernelmodul des Hosts sowie
|
||||
`CAP_NET_ADMIN` und Zugriff auf `/dev/net/tun` im Container:
|
||||
|
||||
- Auf dem **Proxmox-Host** muss das `wireguard`-Kernelmodul geladen sein
|
||||
(`modprobe wireguard`; bei Bedarf `/etc/modules` ergänzen).
|
||||
- Der LXC-Container sollte entweder **privilegiert** betrieben werden, oder
|
||||
als unprivilegierter Container mit gezielten Lockerungen
|
||||
(`lxc.cap.drop` ohne `net_admin`, `lxc.cgroup2.devices.allow: c 10:200 rwm`
|
||||
für `/dev/net/tun`) konfiguriert werden. In der Praxis ist ein
|
||||
privilegierter Container für WireGuard-Hosting deutlich unkomplizierter.
|
||||
- `/dev/net/tun` muss im Container vorhanden und beschreibbar sein
|
||||
(`ls -l /dev/net/tun`); ggf. per Bind-Mount/`lxc.mount.entry` durchreichen.
|
||||
- Die systemd-Unit läuft als `root` mit `AmbientCapabilities=CAP_NET_ADMIN`,
|
||||
weil sie `wg-quick`, `systemctl` und `nft` aufruft — diese Tools benötigen
|
||||
in der Praxis root-Rechte im Container.
|
||||
- Läuft `nftables` bereits als eigener Dienst im Container/Host, sollte der
|
||||
von `wireguard-ui-multi` vorgeschlagene Ruleset (siehe unten) manuell in
|
||||
die bestehende Regelbasis integriert statt blind angewendet werden, um
|
||||
Konflikte mit vorhandenen Tabellen/Chains zu vermeiden.
|
||||
|
||||
## Server- & Peer-Verwaltung
|
||||
|
||||
**Server anlegen** (UI oder `POST /api/servers`): Name, Interface-Name
|
||||
(z. B. `wg-home`), Listen-Port, Adressbereich (z. B. `10.20.22.0/24`), DNS,
|
||||
MTU angeben. Private/Public Key werden serverseitig automatisch erzeugt.
|
||||
|
||||
**Server starten/stoppen/neuladen**: über die Dashboard-Buttons oder
|
||||
`POST /api/servers/{id}/start|stop|reload`. Start schreibt zunächst die
|
||||
`wg-quick`-Config nach `/etc/wireguard/<interface>.conf` und ruft dann
|
||||
`wg-quick up <interface>` auf; Reload nutzt `wg syncconf` für einen
|
||||
Hot-Reload ohne Tunnelabbruch.
|
||||
|
||||
**Peer hinzufügen** (UI oder `POST /api/server/{id}/peer`): Name, optional
|
||||
E-Mail/Beschreibung und Ablaufdatum angeben — Schlüsselpaar und Preshared
|
||||
Key werden automatisch generiert.
|
||||
|
||||
**Config/QR-Code abrufen**: `GET /api/server/{id}/peer/{peerid}/config`
|
||||
liefert die fertige `.conf`-Datei zum Download, `GET
|
||||
/api/server/{id}/peer/{peerid}/qrcode` liefert denselben Inhalt als
|
||||
PNG-QR-Code zum Scannen mit der WireGuard-App.
|
||||
|
||||
### REST-API-Übersicht
|
||||
|
||||
```
|
||||
POST /api/login
|
||||
POST /api/logout
|
||||
|
||||
GET /api/servers
|
||||
POST /api/servers
|
||||
GET /api/servers/{id}
|
||||
PUT /api/servers/{id}
|
||||
DELETE /api/servers/{id}
|
||||
POST /api/servers/{id}/start
|
||||
POST /api/servers/{id}/stop
|
||||
POST /api/servers/{id}/reload
|
||||
GET /api/servers/{id}/config
|
||||
|
||||
GET /api/server/{id}/peers
|
||||
POST /api/server/{id}/peer
|
||||
DELETE /api/server/{id}/peer/{peerid}
|
||||
GET /api/server/{id}/peer/{peerid}/config
|
||||
GET /api/server/{id}/peer/{peerid}/qrcode
|
||||
```sh
|
||||
docker build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD) -t wireguard-ui .
|
||||
```
|
||||
|
||||
Alle Endpunkte außer `/api/login` erfordern einen gültigen Session-Cookie;
|
||||
mutierende Methoden (POST/PUT/DELETE) benötigen zusätzlich den Header
|
||||
`X-CSRF-Token` mit dem beim Login ausgegebenen Token.
|
||||
or
|
||||
|
||||
## Backup / Restore
|
||||
|
||||
Ein automatisiertes Backup-/Restore-Werkzeug ist aktuell **nicht**
|
||||
implementiert. Für ein manuelles Backup genügt es, folgende Pfade zu
|
||||
sichern:
|
||||
|
||||
- die SQLite-Datenbank: `/var/lib/wireguard-ui-multi/wireguard-ui-multi.db`
|
||||
(enthält Server, Peers, Keys, Audit Log, Benutzer)
|
||||
- die generierten Interface-Configs: `/etc/wireguard/*.conf`
|
||||
- ggf. eigene Hook-Skripte: `/etc/wireguard-manager/hooks/`
|
||||
|
||||
Beispiel:
|
||||
|
||||
```bash
|
||||
sudo tar czf wireguard-ui-multi-backup-$(date +%F).tar.gz \
|
||||
/var/lib/wireguard-ui-multi/wireguard-ui-multi.db \
|
||||
/etc/wireguard/*.conf \
|
||||
/etc/wireguard-manager/hooks
|
||||
```sh
|
||||
docker compose build --build-arg=GIT_COMMIT=$(git rev-parse --short HEAD)
|
||||
```
|
||||
|
||||
**Restore**: Dienst stoppen, Archiv an denselben Pfaden entpacken,
|
||||
Berechtigungen prüfen (`chmod 0700` auf das Datenverzeichnis) und Dienst
|
||||
wieder starten:
|
||||
:information_source: A container image is available on [Docker Hub](https://hub.docker.com/r/ngoduykhanh/wireguard-ui)
|
||||
which you can pull and use
|
||||
|
||||
```bash
|
||||
sudo systemctl stop wireguard-ui-multi.service
|
||||
sudo tar xzf wireguard-ui-multi-backup-YYYY-MM-DD.tar.gz -C /
|
||||
sudo systemctl start wireguard-ui-multi.service
|
||||
```
|
||||
docker pull ngoduykhanh/wireguard-ui
|
||||
````
|
||||
|
||||
### Build binary file
|
||||
|
||||
Prepare the assets directory
|
||||
|
||||
```sh
|
||||
./prepare_assets.sh
|
||||
```
|
||||
|
||||
## Migration von einer bestehenden wireguard-ui-Installation
|
||||
Then build your executable
|
||||
|
||||
Für den Umstieg von einer klassischen Single-Interface-Installation
|
||||
(`/etc/wireguard/wg0.conf`) ist ein Migrationswerkzeug vorgesehen, das eine
|
||||
bestehende `wg0.conf` einliest und als ersten verwalteten Server samt seiner
|
||||
Peers importiert. Damit lässt sich eine vorhandene WireGuard-Instanz
|
||||
übernehmen, ohne bestehende Clients neu konfigurieren zu müssen. Details zum
|
||||
genauen Ablauf und den Aufrufoptionen siehe die Implementierung im
|
||||
`wireguard`-Package des Repos, sobald verfügbar; grundsätzlich gilt: vor der
|
||||
Migration ein Backup der bestehenden `wg0.conf` anlegen.
|
||||
```sh
|
||||
go build -o wireguard-ui
|
||||
```
|
||||
|
||||
## Sicherheitshinweise
|
||||
## License
|
||||
|
||||
- **Private Keys werden nie im Frontend/JSON angezeigt** — sie werden
|
||||
ausschließlich serverseitig in generierten `.conf`-Dateien bzw.
|
||||
QR-Codes für einzelne Peers ausgeliefert.
|
||||
- **HTTPS verwenden**: entweder direkt über `--tls-cert`/`--tls-key`, oder
|
||||
die Anwendung hinter einem Reverse Proxy (nginx, Caddy, Traefik) mit
|
||||
TLS-Terminierung betreiben. Ohne TLS gibt der Dienst beim Start eine
|
||||
deutliche Warnung aus.
|
||||
- **Standard-Admin-Passwort sofort ändern**: das beim Erststart einmalig
|
||||
ausgegebene zufällige Passwort sollte direkt nach dem ersten Login
|
||||
geändert werden.
|
||||
- Mutierende API-Aufrufe erfordern einen gültigen Session-Cookie **und**
|
||||
den CSRF-Header `X-CSRF-Token` — Clients/Skripte, die die API direkt
|
||||
ansprechen, müssen sich zunächst über `/api/login` anmelden und den
|
||||
zurückgegebenen Token mitführen.
|
||||
- Die Datenverzeichnisse (`/var/lib/wireguard-ui-multi`) sollten
|
||||
restriktive Berechtigungen (`0700`) behalten, da dort Schlüsselmaterial
|
||||
und Passwort-Hashes liegen.
|
||||
MIT. See [LICENSE](https://github.com/ngoduykhanh/wireguard-ui/blob/master/LICENSE).
|
||||
|
||||
## Support
|
||||
|
||||
If you like the project and want to support it, you can *buy me a coffee* ☕
|
||||
|
||||
<a href="https://www.buymeacoffee.com/khanhngo" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
|
||||
|
||||
Reference in New Issue
Block a user