Skip to content

feat: SNI routing, PROXY protocol, monitoring stack#8

Merged
findias merged 19 commits intomainfrom
develop
Mar 28, 2026
Merged

feat: SNI routing, PROXY protocol, monitoring stack#8
findias merged 19 commits intomainfrom
develop

Conversation

@findias
Copy link
Copy Markdown
Contributor

@findias findias commented Mar 28, 2026

Summary

  • nginx stream SNI routing on port 443 — all VPN traffic through standard HTTPS port
  • PROXY protocol v2 between nginx and Xray (proxy_protocol on / xver: 2) — real client IPs in Xray stats
  • Per-inbound traffic metrics: xray_inbound_uplink/downlink_bytes_total
  • Monitoring role: xray-stats-exporter + VictoriaMetrics + Grafana with dashboards and alerting
  • Raven-subscribe health monitoring in Grafana server-status dashboard
  • Grafana alerting rules: xray-down, raven-subscribe-down, eu/ru-server-down, disk-high
  • xray-stats-exporter: geo IP lookup flags (--log-path, --geo-city-db, --geo-asn-db)
  • Fixes: xray-stats-exporter service user/group vars, binary copy skipped when not provided
  • CI: run tests on develop branch and PRs targeting develop
  • docs: updated README with correct SNI routing architecture, ports, monitoring section

Deploy order (CRITICAL)

When deploying nginx_frontend and Xray inbounds together — always deploy Xray first (--tags xray_inbounds), then nginx.

Test plan

  • CI passing: Xray config (Ansible + xray -test)
  • Xray connects after deploying both components
  • xray_up 1 in exporter metrics
  • Per-inbound metrics appear in Grafana
  • Raven-subscribe health panel shows UP

findias and others added 19 commits March 24, 2026 22:24
Both VPN protocols (VLESS+Reality TCP and VLESS+XHTTP+Reality) now share
port 443 via nginx stream ssl_preread SNI routing on both EU and RU servers.

EU server:
- nginx stream :443 routes by SNI: www.adobe.com → Xray XHTTP (:2053),
  media.zirgate.com → nginx HTTPS (:8443), default → Xray Reality (:4443)
- Xray inbounds bind 127.0.0.1 (no longer exposed directly)
- XHTTP Reality dest changed to www.adobe.com with xPaddingBytes

RU relay:
- Single stream :443 routes by SNI: zirgate.com/my.zirgate.com → local
  nginx HTTPS (:8443), everything else → EU:443
- Removed separate per-protocol stream ports (8444, 2053)

nginx_frontend HTTPS: removed XHTTP proxy location (now handled by stream)
Raven-subscribe: updated inbound_ports comments for port 443
…ra domains

- xray XHTTP scMaxPacketSize: 50000 → 1048576 (1MB) — reduces HTTP round-trips
- relay stream: add relay_extra_eu_https_domains for SNI routing to EU:8443
  (used when a domain's DNS is moved to RU but cert is on EU nginx)
…sites-enabled

- relay stream: remove relay_extra_eu_https_domains (no longer needed)
- nginx_frontend: deploy HTTPS config to sites-enabled/ instead of conf.d/
  (nginx.conf on EU only includes sites-enabled/)
- New role roles/wireguard: installs wireguard-tools, deploys wg0 on
  EU (10.10.0.1) and RU (10.10.0.2), PersistentKeepalive=25s
- role_wireguard.yml playbook applies to both vm_my_srv and vm_my_ru
- monitoring: remove ssh_tunnel_ru task/handler/vars; node_exporter on
  RU now binds to 10.10.0.2:9100 (WireGuard iface); VictoriaMetrics
  scrapes RU via 10.10.0.2:9100 instead of SSH tunnel 127.0.0.1:19100
- monitoring/node_exporter: add ufw allow from 10.10.0.0/24 for RU
- role_monitoring.yml: apply role to both EU and RU hosts; EU-only
  components (VictoriaMetrics, Grafana, exporters) guarded by when
Xray requires non-empty email for StatsService per-user counters.
If user.email is missing or blank, use user.id instead.
Applies to 200-in-vless-reality, 210-in-xhttp, 230/240-in-*-users.
GitHub /releases/latest returns enterprise release (no single-node
tarball). Switch to /releases list and find first release that has
victoria-metrics-linux-{arch}-vX.Y.Z.tar.gz (non-enterprise, non-cluster).
Also fix task order: detect arch before fetching releases list.
server-status: add unique_users (stat), total_connections (stat),
routing requests rate (freedom vs blocked), Xray heap memory timeseries.

xray-users-traffic: replace cumulative counter tables with bar gauges
using increase($__range) — shows traffic per user for selected period.
…ibe monitoring, Grafana alerts

- xray-stats-exporter: add xray_inbound_uplink/downlink_bytes_total metrics
  by querying inbound>>> pattern alongside user>>> in StatsService
- scrape.yml: add raven-subscribe job scraping /health (up=0 on failure)
- dashboards: add inbound traffic panels and sort_desc on user top charts
- server-status: add Raven-subscribe UP/DOWN status and latency panels
- grafana-alerting.yml: provision 5 alert rules (xray down, raven-subscribe
  down, EU/RU server down, EU disk >85%)
Geo metrics (country/city) not available — Xray access.log shows
127.0.0.1 after nginx proxy_protocol was added. Removed geo row
and shifted inbound panels up.
…t ports

- Fix architecture diagrams: SNI routing on :443, ports 4443/2053/8443
- Add nginx_frontend PROXY protocol notes and deploy order warning
- Add monitoring role description (xray-stats-exporter, VictoriaMetrics, Grafana)
- Add Monitoring section with Grafana dashboard and alerting description
- Update nginx_frontend and relay config variable tables
- Add xray-stats-exporter to Related Projects
- Sync README.ru.md with EN changes
feat: SNI routing v2, PROXY protocol, monitoring improvements
@findias findias merged commit 4fc234d into main Mar 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant