Правки локального размещения дева, перенос тунеля в контейнер

This commit is contained in:
2026-06-17 04:27:11 +03:00
parent b04fbb2e17
commit 7e8b748caf
14 changed files with 249 additions and 152 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/bin/sh
# SSH reverse-туннель из контейнера на VPS:
# VPS:127.0.0.1:$VPS_TUNNEL_PORT -> $UPSTREAM (сервис app по сети compose)
# Ключ монтируется снаружи в /key/id_tunnel (см. docker-compose*.yml).
set -eu
: "${VPS_TUNNEL_HOST:?VPS_TUNNEL_HOST is required}"
VPS_TUNNEL_USER="${VPS_TUNNEL_USER:-tunnel}"
: "${VPS_TUNNEL_PORT:?VPS_TUNNEL_PORT is required}"
UPSTREAM="${UPSTREAM:-app:8000}"
# Копируем ключ и выставляем строгие права (с хоста права могут не годиться, особенно с Windows).
mkdir -p /root/.ssh
cp /key/id_tunnel /root/.ssh/id_tunnel
chmod 600 /root/.ssh/id_tunnel
echo "[tunnel] -R ${VPS_TUNNEL_PORT}:${UPSTREAM} -> ${VPS_TUNNEL_USER}@${VPS_TUNNEL_HOST}"
exec ssh -N \
-o BatchMode=yes \
-o ServerAliveInterval=30 -o ServerAliveCountMax=3 \
-o ExitOnForwardFailure=yes \
-o StrictHostKeyChecking=accept-new \
-o UserKnownHostsFile=/root/.ssh/known_hosts \
-i /root/.ssh/id_tunnel \
-R "${VPS_TUNNEL_PORT}:${UPSTREAM}" \
"${VPS_TUNNEL_USER}@${VPS_TUNNEL_HOST}"