feat(remnawave): declarative panel on core-net and SelfSteal node on ger-nod-02
ansible-core-mon / deploy (push) Successful in 25s
ansible-core-secrets / deploy (push) Canceled after 0s
ansible-ger-nod-02 / deploy (push) Canceled after 0s
ansible-opnsense / deploy (push) Canceled after 0s
ansible-rus-central / deploy (push) Canceled after 0s
ansible-core-net / deploy (push) Failing after 26s

Add Remnawave panel+subscription behind Traefik (rw/sub.gunihome.ru), API bootstrap into Infisical, and ger-nod-02 node with Cloudflare DNS-01 SelfSteal (yali.gunis.top). Leaves remna.gunihome.ru on Golova untouched.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
karpenokandCursor committed 2026-11-11 22:15:45 +07:00
1 parent a0ec829eee
commit 8caaddc779
25 files changed
+1401 -5

No files matched your search

@@ -0,0 +1,279 @@
#!/bin/bash
set -euo pipefail
API_BASE="https://${RW_PANEL_DOMAIN}/api"
CURL=(curl -fsSk --resolve "${RW_PANEL_DOMAIN}:443:127.0.0.1")
AUTH_HDR=()
admin_created=0
token_updated=0
profile_created=0
node_created=0
host_created=0
node_secret=""
active_token="${RW_API_TOKEN:-}"
api() {
local method="$1"; shift
local path="$1"; shift
if [ "${#AUTH_HDR[@]}" -gt 0 ]; then
"${CURL[@]}" -X "$method" "${AUTH_HDR[@]}" -H "Content-Type: application/json" "${API_BASE}${path}" "$@"
else
"${CURL[@]}" -X "$method" -H "Content-Type: application/json" "${API_BASE}${path}" "$@"
fi
}
json_first() {
jq -r "$1" 2>/dev/null || true
}
status_json=$("${CURL[@]}" "${API_BASE}/auth/status")
is_login=$(printf '%s' "${status_json}" | jq -r '.response.isLoginAllowed // .isLoginAllowed // false')
is_register=$(printf '%s' "${status_json}" | jq -r '.response.isRegisterAllowed // .isRegisterAllowed // false')
if [ "${is_register}" = "true" ]; then
reg_payload=$(jq -n --arg u "$RW_ADMIN_USER" --arg p "$RW_ADMIN_PASS" '{username: $u, password: $p}')
api POST /auth/register -d "${reg_payload}" >/dev/null
admin_created=1
is_login=true
fi
login_ok=0
if [ -n "${active_token}" ]; then
code=$("${CURL[@]}" -o /dev/null -w '%{http_code}' \
-H "Authorization: Bearer ${active_token}" "${API_BASE}/nodes/" || true)
if [ "${code}" = "200" ]; then
login_ok=1
AUTH_HDR=(-H "Authorization: Bearer ${active_token}")
fi
fi
if [ "${login_ok}" -eq 0 ]; then
login_payload=$(jq -n --arg u "$RW_ADMIN_USER" --arg p "$RW_ADMIN_PASS" '{username: $u, password: $p}')
login_resp=$(api POST /auth/login -d "${login_payload}")
access=$(printf '%s' "${login_resp}" | jq -r '.response.accessToken // .accessToken // empty')
if [ -z "${access}" ]; then
echo "Не удалось войти в панель Remnawave" >&2
printf '%s\n' "${login_resp}" >&2
exit 1
fi
AUTH_HDR=(-H "Authorization: Bearer ${access}")
tokens_json=$(api GET /tokens/ || echo '{"response":[]}')
old_uuid=$(printf '%s' "${tokens_json}" | jq -r --arg n "$RW_TOKEN_NAME" '
(.response // .)
| if type=="array" then . elif .tokens then .tokens else [] end
| map(select(.tokenName == $n or .name == $n))
| .[0].uuid // empty')
if [ -n "${old_uuid}" ]; then
api DELETE "/tokens/${old_uuid}" >/dev/null || true
fi
token_payload=$(jq -n --arg n "$RW_TOKEN_NAME" '{tokenName: $n}')
token_resp=$(api POST /tokens/ -d "${token_payload}")
active_token=$(printf '%s' "${token_resp}" | jq -r '
.response.token // .response.apiToken // .token // .apiToken // empty')
if [ -z "${active_token}" ]; then
echo "Не удалось создать API-токен" >&2
printf '%s\n' "${token_resp}" >&2
exit 1
fi
AUTH_HDR=(-H "Authorization: Bearer ${active_token}")
token_updated=1
fi
profiles_json=$(api GET /config-profiles/)
profile_uuid=$(printf '%s' "${profiles_json}" | jq -r --arg n "$RW_PROFILE_NAME" '
(.response.configProfiles // .response // [])
| map(select(.name == $n)) | .[0].uuid // empty')
pub=""
if [ -z "${profile_uuid}" ]; then
key_resp=$(api GET /system/tools/x25519/generate 2>/dev/null || api GET /keygen/ 2>/dev/null || echo '{}')
priv=$(printf '%s' "${key_resp}" | jq -r '
.response.privateKey // .response.privKey // .privateKey // .privKey // empty')
pub=$(printf '%s' "${key_resp}" | jq -r '
.response.publicKey // .response.pubKey // .publicKey // .pubKey // empty')
if [ -z "${priv}" ]; then
echo "Не удалось сгенерировать X25519 ключи Reality" >&2
printf '%s\n' "${key_resp}" >&2
exit 1
fi
short_id=$(openssl rand -hex 8)
profile_config=$(sed \
-e "s|__REALITY_PRIVATE_KEY__|${priv}|g" \
-e "s|__REALITY_SHORT_ID__|${short_id}|g" \
"$RW_PROFILE_FILE")
create_profile=$(jq -n --arg n "$RW_PROFILE_NAME" --argjson c "${profile_config}" '{name: $n, config: $c}')
profile_resp=$(api POST /config-profiles/ -d "${create_profile}")
profile_uuid=$(printf '%s' "${profile_resp}" | jq -r '.response.uuid // .uuid // empty')
if [ -z "${profile_uuid}" ]; then
echo "Не удалось создать config profile" >&2
printf '%s\n' "${profile_resp}" >&2
exit 1
fi
profile_created=1
fi
profile_full=$(api GET "/config-profiles/${profile_uuid}")
inbound_uuid=$(printf '%s' "${profile_full}" | jq -r --arg t "$RW_INBOUND_TAG" '
(.response.inbounds // .inbounds // [])
| map(select(.tag == $t)) | .[0].uuid // empty')
if [ -z "${inbound_uuid}" ]; then
inbounds_json=$(api GET "/config-profiles/${profile_uuid}/inbounds" 2>/dev/null || echo '{}')
inbound_uuid=$(printf '%s' "${inbounds_json}" | jq -r --arg t "$RW_INBOUND_TAG" '
(.response // .)
| if type=="array" then . else (.inbounds // []) end
| map(select(.tag == $t)) | .[0].uuid // empty')
fi
if [ -z "${inbound_uuid}" ]; then
echo "Не найден inbound ${RW_INBOUND_TAG} в профиле ${profile_uuid}" >&2
exit 1
fi
nodes_json=$(api GET /nodes/)
node_uuid=$(printf '%s' "${nodes_json}" | jq -r --arg n "$RW_NODE_NAME" '
(.response // []) | map(select(.name == $n)) | .[0].uuid // empty')
node_secret="${RW_NODE_SECRET:-}"
if [ -z "${node_uuid}" ]; then
node_payload=$(jq -n \
--arg name "$RW_NODE_NAME" \
--arg addr "$RW_NODE_ADDR" \
--argjson port "$RW_NODE_PORT" \
--arg cc "$RW_NODE_CC" \
--arg pu "$profile_uuid" \
--arg iu "$inbound_uuid" \
'{
name: $name,
address: $addr,
port: $port,
countryCode: $cc,
configProfile: {
activeConfigProfileUuid: $pu,
activeInbounds: [$iu]
}
}')
node_resp=$(api POST /nodes/ -d "${node_payload}" 2>/dev/null || true)
node_uuid=$(printf '%s' "${node_resp}" | jq -r '.response.uuid // .uuid // empty')
node_secret=$(printf '%s' "${node_resp}" | jq -r '
.response.secretKey // .response.SECRET_KEY // .secretKey // .SECRET_KEY // empty')
if [ -z "${node_uuid}" ]; then
node_payload=$(jq -n \
--arg name "$RW_NODE_NAME" \
--arg addr "$RW_NODE_ADDR" \
--argjson port "$RW_NODE_PORT" \
--arg cc "$RW_NODE_CC" \
'{name: $name, address: $addr, port: $port, countryCode: $cc}')
node_resp=$(api POST /nodes/ -d "${node_payload}")
node_uuid=$(printf '%s' "${node_resp}" | jq -r '.response.uuid // .uuid // empty')
node_secret=$(printf '%s' "${node_resp}" | jq -r '
.response.secretKey // .response.SECRET_KEY // .secretKey // .SECRET_KEY // empty')
fi
if [ -z "${node_uuid}" ]; then
echo "Не удалось создать ноду" >&2
printf '%s\n' "${node_resp}" >&2
exit 1
fi
node_created=1
fi
node_update=$(jq -n \
--arg u "$node_uuid" \
--arg pu "$profile_uuid" \
--arg iu "$inbound_uuid" \
'{
uuid: $u,
configProfile: {
activeConfigProfileUuid: $pu,
activeInbounds: [$iu]
}
}')
api PATCH /nodes/ -d "${node_update}" >/dev/null 2>&1 \
|| api PUT /nodes/ -d "${node_update}" >/dev/null 2>&1 \
|| true
if [ -z "${node_secret}" ] && [ "${node_created}" -eq 1 ]; then
node_full=$(api GET "/nodes/${node_uuid}")
node_secret=$(printf '%s' "${node_full}" | jq -r '
.response.secretKey // .response.SECRET_KEY // .secretKey // empty')
fi
hosts_json=$(api GET /hosts/)
host_uuid=$(printf '%s' "${hosts_json}" | jq -r --arg a "$RW_SELFSTEAL" '
(.response // []) | map(select(.address == $a)) | .[0].uuid // empty')
if [ -z "${host_uuid}" ]; then
host_payload=$(jq -n \
--arg remark "$RW_HOST_REMARK" \
--arg addr "$RW_SELFSTEAL" \
--arg path "$RW_XHTTP_PATH" \
--arg sni "$RW_SELFSTEAL" \
--arg host "$RW_SELFSTEAL" \
--arg pu "$profile_uuid" \
--arg iu "$inbound_uuid" \
--arg nu "$node_uuid" \
'{
remark: $remark,
address: $addr,
port: 443,
path: $path,
sni: $sni,
host: $host,
fingerprint: "chrome",
isDisabled: false,
securityLayer: "DEFAULT",
alpn: "h2",
xHttpExtraParams: {
xmux: {
maxConcurrency: "16-32",
hMaxRequestTimes: "600-900",
hMaxReusableSecs: "1800-3000"
},
noSSEHeader: true,
xPaddingBytes: "100-1000"
},
inbound: {
configProfileUuid: $pu,
configProfileInboundUuid: $iu
},
nodes: [$nu]
}')
host_resp=$(api POST /hosts/ -d "${host_payload}")
host_uuid=$(printf '%s' "${host_resp}" | jq -r '.response.uuid // .uuid // empty')
if [ -z "${host_uuid}" ]; then
echo "Не удалось создать host" >&2
printf '%s\n' "${host_resp}" >&2
exit 1
fi
host_created=1
fi
jq -n \
--arg api_token "${active_token}" \
--arg node_secret "${node_secret}" \
--arg profile_uuid "${profile_uuid}" \
--arg node_uuid "${node_uuid}" \
--arg host_uuid "${host_uuid}" \
--arg reality_pub "${pub}" \
--argjson admin_created "${admin_created}" \
--argjson token_updated "${token_updated}" \
--argjson profile_created "${profile_created}" \
--argjson node_created "${node_created}" \
--argjson host_created "${host_created}" \
'{
api_token: $api_token,
node_secret: $node_secret,
profile_uuid: $profile_uuid,
node_uuid: $node_uuid,
host_uuid: $host_uuid,
reality_public_key: $reality_pub,
admin_created: ($admin_created == 1),
token_updated: ($token_updated == 1),
profile_created: ($profile_created == 1),
node_created: ($node_created == 1),
host_created: ($host_created == 1),
changed: (($admin_created + $token_updated + $profile_created + $node_created + $host_created) > 0)
}'
@@ -0,0 +1,100 @@
x-common: &common
ulimits:
nofile:
soft: 1048576
hard: 1048576
restart: always
networks:
- remnawave-network
x-logging: &logging
logging:
driver: json-file
options:
max-size: 100m
max-file: 5
x-env: &env
env_file: .env
services:
remnawave:
image: {{ remnawave_backend_image }}
container_name: remnawave
hostname: remnawave
<<: [*common, *logging, *env]
volumes:
- valkey-socket:/var/run/valkey
ports:
- "127.0.0.1:{{ remnawave_app_port }}:{{ remnawave_app_port }}"
- "127.0.0.1:{{ remnawave_metrics_port }}:{{ remnawave_metrics_port }}"
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:{{ remnawave_metrics_port }}/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
depends_on:
remnawave-db:
condition: service_healthy
remnawave-redis:
condition: service_healthy
remnawave-db:
image: {{ remnawave_postgres_image }}
container_name: remnawave-db
hostname: remnawave-db
shm_size: 512mb
<<: [*common, *logging, *env]
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
- TZ=UTC
ports:
- "127.0.0.1:6767:5432"
volumes:
- remnawave-db-data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 3s
timeout: 10s
retries: 3
remnawave-redis:
image: {{ remnawave_redis_image }}
container_name: remnawave-redis
hostname: remnawave-redis
<<: [*common, *logging]
volumes:
- valkey-socket:/var/run/valkey
command: >
valkey-server
--save ""
--appendonly no
--maxmemory-policy noeviction
--loglevel warning
--unixsocket /var/run/valkey/valkey.sock
--unixsocketperm 777
--port 0
healthcheck:
test: ["CMD", "valkey-cli", "-s", "/var/run/valkey/valkey.sock", "ping"]
interval: 3s
timeout: 3s
retries: 3
networks:
remnawave-network:
name: remnawave-network
driver: bridge
external: false
volumes:
remnawave-db-data:
name: remnawave-db-data
driver: local
external: false
valkey-socket:
name: valkey-socket
driver: local
external: false
@@ -0,0 +1,59 @@
### APP ###
APP_PORT={{ remnawave_app_port }}
METRICS_PORT={{ remnawave_metrics_port }}
### API ###
API_INSTANCES=1
### DATABASE ###
DATABASE_URL="postgresql://postgres:{{ remnawave_postgres_password }}@remnawave-db:5432/postgres"
### REDIS ###
REDIS_SOCKET=/var/run/valkey/valkey.sock
### Secrets ###
APP_SECRET={{ remnawave_app_secret }}
### TELEGRAM NOTIFICATIONS ###
IS_TELEGRAM_NOTIFICATIONS_ENABLED=false
TELEGRAM_BOT_TOKEN=change_me
TELEGRAM_NOTIFY_USERS=change_me
TELEGRAM_NOTIFY_NODES=change_me
TELEGRAM_NOTIFY_CRM=change_me
TELEGRAM_NOTIFY_SERVICE=change_me
TELEGRAM_NOTIFY_TBLOCKER=change_me
### PANEL DOMAIN ###
PANEL_DOMAIN={{ remnawave_panel_domain }}
### FRONT_END ###
FRONT_END_DOMAIN={{ remnawave_panel_domain }}
### SUBSCRIPTION PUBLIC DOMAIN ###
SUB_PUBLIC_DOMAIN={{ remnawave_sub_domain }}
### PROMETHEUS ###
METRICS_USER=admin
METRICS_PASS={{ remnawave_metrics_pass }}
### Webhook ###
WEBHOOK_ENABLED=false
WEBHOOK_URL=https://your-webhook-url.com/endpoint
WEBHOOK_SECRET_HEADER={{ remnawave_webhook_secret }}
BANDWIDTH_USAGE_NOTIFICATIONS_ENABLED=false
BANDWIDTH_USAGE_NOTIFICATIONS_THRESHOLD=[60, 80]
NOT_CONNECTED_USERS_NOTIFICATIONS_ENABLED=false
NOT_CONNECTED_USERS_NOTIFICATIONS_AFTER_HOURS=[6, 24, 48]
EXPIRATION_NOTIFICATIONS_ENABLED=false
EXPIRATION_NOTIFICATIONS=[-72, -48, -24, 24]
EXPORT_TO_STREAM_ENABLED=false
EXPORT_TO_STREAM_MAXLEN=3000
SHORT_UUID_METHOD=nanoid
SHORT_UUID_LENGTH=16
SERVICE_SNI_VERIFICATION=true
### Database container ###
POSTGRES_USER=postgres
POSTGRES_PASSWORD={{ remnawave_postgres_password }}
POSTGRES_DB=postgres
@@ -0,0 +1,23 @@
services:
remnawave-subscription-page:
image: {{ remnawave_subscription_image }}
container_name: remnawave-subscription-page
hostname: remnawave-subscription-page
restart: always
env_file:
- .env
ports:
- "127.0.0.1:{{ remnawave_subscription_port }}:{{ remnawave_subscription_port }}"
networks:
- remnawave-network
logging:
driver: json-file
options:
max-size: 30m
max-file: 5
networks:
remnawave-network:
name: remnawave-network
driver: bridge
external: true
@@ -0,0 +1,5 @@
APP_PORT={{ remnawave_subscription_port }}
REMNAWAVE_PANEL_URL=http://remnawave:{{ remnawave_app_port }}
REMNAWAVE_API_TOKEN={{ remnawave_api_token }}
CUSTOM_SUB_PREFIX=
TRUST_PROXY=1