Refactor environment variables with shorter names and add comprehensive override support

- Rename OVERRIDE_INTERFACE_* to WG_* (shorter, non-conflicting)
- Add interface overrides: WG_PORT, WG_DEVICE, WG_MTU, WG_IPV4_CIDR, WG_IPV6_CIDR, WG_ENABLED
- Add client config overrides: WG_HOST, WG_CLIENT_PORT, WG_DEFAULT_DNS, WG_DEFAULT_ALLOWED_IPS, WG_DEFAULT_MTU, WG_DEFAULT_PERSISTENT_KEEPALIVE
- Add general config overrides: WG_SESSION_TIMEOUT, WG_METRICS_PROMETHEUS, WG_METRICS_JSON
- Update all API endpoints to apply and filter overrides
- Update documentation with all new environment variables
- Exclude AmneziaWG parameters (j*, s*, i*, h*) as requested

Co-authored-by: kaaax0815 <32197462+kaaax0815@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-14 13:25:22 +00:00
parent 5fd3ee9843
commit 67185192fd
9 changed files with 189 additions and 23 deletions
@@ -25,11 +25,35 @@ This option can be removed in the future, as more devices support IPv6.
These environment variables allow you to override settings that would normally be configured through the Admin Panel. When set, these values take precedence over database settings and cannot be changed through the Web UI.
| Env | Example | Description |
| --------------------------- | ------- | ---------------------------------------------------- |
| `OVERRIDE_INTERFACE_PORT` | `51820` | Override the WireGuard interface listening port |
| `OVERRIDE_INTERFACE_DEVICE` | `eth1` | Override the network device/interface |
| `OVERRIDE_INTERFACE_MTU` | `1420` | Override the MTU (Maximum Transmission Unit) setting |
### Interface Settings
| Env | Example | Description |
| -------------- | ----------------- | ---------------------------------- |
| `WG_PORT` | `51820` | WireGuard interface listening port |
| `WG_DEVICE` | `eth0` | Network device/interface |
| `WG_MTU` | `1420` | Maximum Transmission Unit |
| `WG_IPV4_CIDR` | `10.8.0.0/24` | IPv4 CIDR range |
| `WG_IPV6_CIDR` | `fdcc::/112` | IPv6 CIDR range |
| `WG_ENABLED` | `true` or `false` | Whether the interface is enabled |
### Client Connection Settings
| Env | Example | Description |
| --------------------------------- | ----------------- | ---------------------------------------- |
| `WG_HOST` | `vpn.example.com` | Host clients will connect to |
| `WG_CLIENT_PORT` | `51820` | Port clients will connect to |
| `WG_DEFAULT_DNS` | `1.1.1.1,8.8.8.8` | Default DNS servers for clients |
| `WG_DEFAULT_ALLOWED_IPS` | `0.0.0.0/0,::/0` | Default allowed IPs for clients |
| `WG_DEFAULT_MTU` | `1420` | Default MTU for clients |
| `WG_DEFAULT_PERSISTENT_KEEPALIVE` | `25` | Default persistent keepalive for clients |
### General Settings
| Env | Example | Description |
| ----------------------- | ----------------- | -------------------------- |
| `WG_SESSION_TIMEOUT` | `3600` | Session timeout in seconds |
| `WG_METRICS_PROMETHEUS` | `true` or `false` | Enable Prometheus metrics |
| `WG_METRICS_JSON` | `true` or `false` | Enable JSON metrics |
/// warning | Override Behavior
@@ -43,3 +67,11 @@ When these override environment variables are set:
These overrides are useful for containerized environments where configuration should be controlled externally.
///
/// note | Note on Port Variables
- `WG_PORT` - The port WireGuard listens on (interface port)
- `WG_CLIENT_PORT` - The port clients connect to (endpoint port, usually same as `WG_PORT`)
- `PORT` - The port the Web UI listens on (HTTP server port)
///