Prometheus on a node; panel under a URL prefix; open ports on migrate import
A panel without VPN (e.g. after the move) can use a Prometheus that lives on a node, such as the one with history left on the old server (node #0). Both directions go through the agent's WSS: the node's Prometheus scrapes 127.0.0.1:AGENT_METRICS_PORT/metrics, the agent checks its token and asks core (metrics → metrics_res, the same exposition as /metrics, at most once per 5 s per connection); the monitor tab reads it back through the agent, which forwards only GET /-/ready and /api/v1/query[_range]. The panel finds it by itself (local first, then the lowest-id node), and the install/remove buttons work on a panel without VPN. `monitor install` on a node without its own panel picks AGENT_METRICS_PORT, writes it to cli.env and restarts the agent; on the old server it keeps the collected data. The panel works behind nginx in a subfolder: relative asset and API paths, relative directory redirects, and the client address from X-Forwarded-For / X-Real-IP only from trusted proxies (loopback, TRUST_PROXY). migrate import opens the moved SUB_PORT/NODE_PORT in UFW when it is active.
This commit is contained in:
@@ -57,6 +57,34 @@ AWG_GEN=auto bash <(curl -Ls https://raw.githubusercontent.com/maeneko/forgettin
|
||||
`REPO_BASE`, `REPO_FALLBACK`, `ARCHIVE_URL`, `BRAND` перед запуском установщика
|
||||
(подробности — в комментариях `install.sh` и в `.env`).
|
||||
|
||||
### Панель за nginx
|
||||
|
||||
Панель работает и в корне домена, и в любой подпапке — пути в ней относительные,
|
||||
настраивать сам префикс не нужно. Пример для `https://example.com/forgetting/`
|
||||
(`39708` — `PORT` панели из `/opt/awg-control/cli/cli.env`):
|
||||
|
||||
```nginx
|
||||
location = /forgetting { return 301 /forgetting/; }
|
||||
location ^~ /forgetting/ {
|
||||
proxy_pass http://127.0.0.1:39708/; # слэш в конце срезает префикс
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
```
|
||||
|
||||
Адрес клиента панель берёт из `X-Forwarded-For` / `X-Real-IP` только от доверенного
|
||||
прокси: с этой же машины (loopback) — всегда, с других адресов — если они перечислены
|
||||
в `TRUST_PROXY` в `cli.env` (IP или сети через запятую, например
|
||||
`TRUST_PROXY=10.0.0.5,192.168.1.0/24`), после чего `awg-ctrl restart`. От остальных
|
||||
заголовки игнорируются. Без этого все входы шли бы с адреса прокси и делили один
|
||||
лимит неудачных попыток.
|
||||
|
||||
Сам порт панели после этого можно закрыть снаружи (`ufw deny <PORT>/tcp`) — порты
|
||||
подписки (`SUB_PORT`) и хаба нод (`NODE_PORT`) должны оставаться открытыми: клиенты
|
||||
и ноды ходят на них напрямую, не через nginx.
|
||||
|
||||
## API
|
||||
|
||||
Наружу смотрят две независимые поверхности. **Публичный API** `/api/v1` —
|
||||
|
||||
Reference in New Issue
Block a user