From d97ae64c850f40b9d07e6d26cccdc9e70860856e Mon Sep 17 00:00:00 2001 From: lofyer Date: Sat, 4 Jul 2026 07:19:33 +0800 Subject: [PATCH] Move deploy config to .env with wg1/51821 defaults for server+client coexistence Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --- .env.example | 18 ++++++++++++++++++ .gitignore | 2 ++ docker-compose.yml | 22 +++++++++------------- 3 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e8674a2 --- /dev/null +++ b/.env.example @@ -0,0 +1,18 @@ +# Copy to .env and fill in. .env is gitignored. + +# Public IP or domain that clients use to reach this server (required) +WG_HOST= + +# WireGuard interface and port managed by the panel. +# Use wg1/51821 so it can coexist with a local wg0 client tunnel. +WG_INTERFACE=wg1 +WG_PORT=51821 +WG_SUBNET=10.8.0.0/24 +WG_DNS=8.8.8.8 + +# Admin panel login +ADMIN_USERNAME=admin +ADMIN_PASSWORD=password + +# Session signing / key encryption secret. Generate with: openssl rand -hex 32 +SECRET_KEY=secret diff --git a/.gitignore b/.gitignore index f8f9839..074891b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ __pycache__/ *.pyc data/ +wg-admin-data/ +wg-config/ .env diff --git a/docker-compose.yml b/docker-compose.yml index 124e0e4..922f61f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,21 +11,17 @@ services: devices: - /dev/net/tun:/dev/net/tun ports: - - "51820:51820/udp" + - "${WG_PORT:-51821}:${WG_PORT:-51821}/udp" - "127.0.0.1:8000:8000/tcp" environment: - WG_INTERFACE: wg0 + WG_INTERFACE: ${WG_INTERFACE:-wg1} WG_HOST: ${WG_HOST:?set WG_HOST to your public IP or domain} - WG_PORT: "51820" - WG_SUBNET: 10.8.0.0/24 - WG_DNS: 1.1.1.1 + WG_PORT: ${WG_PORT:-51821} + WG_SUBNET: ${WG_SUBNET:-10.8.0.0/24} + WG_DNS: ${WG_DNS:-8.8.8.8} ADMIN_USERNAME: ${ADMIN_USERNAME:-admin} - ADMIN_PASSWORD: ${ADMIN_PASSWORD:?set ADMIN_PASSWORD} - SECRET_KEY: ${SECRET_KEY:?set SECRET_KEY to a long random string} + ADMIN_PASSWORD: ${ADMIN_PASSWORD:?set ADMIN_PASSWORD in .env} + SECRET_KEY: ${SECRET_KEY:?set SECRET_KEY in .env} volumes: - - wg-admin-data:/opt/wireguard-admin/data - - wg-config:/etc/wireguard - -volumes: - wg-admin-data: - wg-config: + - ./wg-admin-data:/opt/wireguard-admin/data + - ./wg-config:/etc/wireguard