Fix port 21121 connection refused in Docker (API_HOST binding)

Root cause: config.js defaults apiHost to 127.0.0.1 (localhost-only).
Inside Docker containers, this means port 21121 only listens on the
loopback interface, making it unreachable from outside the container
despite docker port mapping.

docker-compose.single.yml already had API_HOST=0.0.0.0, but
docker-compose.yml (multi-container) and docker-compose.quick.yml
(GHCR pre-built) were missing it.

Fixes:
- docker-compose.yml: Add HOST=0.0.0.0 and API_HOST=0.0.0.0
- docker-compose.quick.yml: Add HOST=0.0.0.0 and API_HOST=0.0.0.0
- Dockerfile.console: Add ENV API_HOST=0.0.0.0
- Dockerfile (single): Add ENV API_HOST=0.0.0.0
- docker/entrypoint.sh: Export API_HOST and HOST defaults
- docker/supervisord.conf: Add API_HOST and HOST to console env

Fixes #78
This commit is contained in:
UNITRONIX
2026-04-06 17:03:11 +02:00
parent 2b61726da6
commit 3a73870706
6 changed files with 12 additions and 0 deletions
+1
View File
@@ -100,6 +100,7 @@ ENV NODE_ENV=production
ENV PORT=5000
ENV SIGNAL_PORT=21116
ENV HOST=0.0.0.0
ENV API_HOST=0.0.0.0
ENV DATA_DIR=/app/data
ENV RUSTDESK_PATH=/opt/rustdesk
ENV DB_PATH=/opt/rustdesk/db_v2.sqlite3
+1
View File
@@ -56,6 +56,7 @@ RUN mkdir -p /app/data /opt/rustdesk && \
ENV NODE_ENV=production
ENV PORT=5000
ENV HOST=0.0.0.0
ENV API_HOST=0.0.0.0
ENV DATA_DIR=/app/data
ENV RUSTDESK_PATH=/opt/rustdesk
ENV DB_PATH=/app/data/db_v2.sqlite3
+2
View File
@@ -60,6 +60,8 @@ services:
environment:
- NODE_ENV=production
- PORT=5000
- HOST=0.0.0.0
- API_HOST=0.0.0.0
- SERVER_BACKEND=betterdesk
- BETTERDESK_API_URL=http://betterdesk-server:21114/api
- RUSTDESK_PATH=/opt/rustdesk
+2
View File
@@ -66,6 +66,8 @@ services:
environment:
- NODE_ENV=production
- PORT=5000
- HOST=0.0.0.0
- API_HOST=0.0.0.0
- SERVER_BACKEND=betterdesk
- HBBS_API_URL=http://betterdesk-server:21114/api
- BETTERDESK_API_URL=http://betterdesk-server:21114/api
+4
View File
@@ -79,6 +79,10 @@ fi
# Ensure Go server uses correct signal port (not NODE.js PORT)
export SIGNAL_PORT="${SIGNAL_PORT:-21116}"
# Ensure Node.js Client API binds to all interfaces (not just localhost)
export API_HOST="${API_HOST:-0.0.0.0}"
export HOST="${HOST:-0.0.0.0}"
# Relay server address: if not explicitly set, try to auto-detect public IP.
# Inside Docker, the Go server's own detection may return the container's
# internal IP (172.x.x.x) which is unreachable by remote clients.
+2
View File
@@ -56,4 +56,6 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
; Ensure Client API binds to all interfaces inside container
environment=API_HOST="0.0.0.0",HOST="0.0.0.0"
priority=200