mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-10-30 23:51:57 +01:00
Adds an opt-in HTTPS layer without touching anything for existing installs. The proxy is a service in docker-compose.yml behind the "https" Compose profile, activated with COMPOSE_PROFILES=https in .env. That keeps the whole setup inside files git owns while the switch lives in a file it ignores -- important because scripts/update.sh runs `git pull`, so any user edit to a tracked compose file would break the next update with a merge conflict. mcupdate needs no change: compose reads COMPOSE_PROFILES from .env itself. Both services share the project's default network, so the proxy forwards to http://mc-webui:5000 internally; MC_BIND_ADDRESS lets the plain-HTTP port be restricted to loopback once HTTPS works, and MC_TRUST_PROXY turns on ProxyFix so the app sees the real client address and scheme. Also fixes copying over plain HTTP. navigator.clipboard only exists in a secure context, and 9 call sites across 5 entry points used it with no fallback, so copy buttons silently did nothing on a LAN address. They now share clipboard-utils.js, loaded via _head_i18n.html (the one include every entry point already has), which falls back to execCommand. Verified locally against the real stack: self-signed cert uploaded to NPM, proxy host created, app served over HTTPS with socket.io upgrading to a real wss:// WebSocket (transport "websocket"), and the clipboard fallback checked end-to-end by pasting back what it copied over http://. Two findings from that run are documented in docs/https-setup.md: NPM 2.15 dropped the default admin@example.com account for a setup wizard, and its default 443 server now refuses connections without SNI -- which is every connection made to a bare IP address. docker/npm-default-site.conf is the opt-in way around that, mounted writable (a :ro mount aborts s6 init and leaves nginx not listening at all). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
73 lines
2.7 KiB
YAML
73 lines
2.7 KiB
YAML
# mc-webui v2 — single container with direct device access
|
|
services:
|
|
mc-webui:
|
|
build: .
|
|
container_name: mc-webui
|
|
restart: unless-stopped
|
|
# MC_BIND_ADDRESS=127.0.0.1 keeps the plain-HTTP port off the network once
|
|
# HTTPS is up (docs/https-setup.md). Default 0.0.0.0 = reachable as before.
|
|
ports:
|
|
- "${MC_BIND_ADDRESS:-0.0.0.0}:${FLASK_PORT:-5000}:${FLASK_PORT:-5000}"
|
|
# Grant access to serial devices for auto-detection
|
|
# Major 188 = ttyUSB (CP2102, CH340), Major 166 = ttyACM (ESP32-S3)
|
|
device_cgroup_rules:
|
|
- 'c 188:* rmw'
|
|
- 'c 166:* rmw'
|
|
# NET_ADMIN + NET_RAW for BLE scanning (no overhead when BLE unused)
|
|
cap_add:
|
|
- NET_ADMIN
|
|
- NET_RAW
|
|
volumes:
|
|
- "${MC_CONFIG_DIR:-./data}:/data:rw"
|
|
- "/dev:/dev"
|
|
- "/var/run/dbus:/var/run/dbus" # BlueZ D-Bus (for BLE)
|
|
environment:
|
|
- MC_SERIAL_PORT=${MC_SERIAL_PORT:-auto}
|
|
- MC_DEVICE_NAME=${MC_DEVICE_NAME:-MeshCore}
|
|
- MC_CONFIG_DIR=/data
|
|
- MC_TCP_HOST=${MC_TCP_HOST:-}
|
|
- MC_TCP_PORT=${MC_TCP_PORT:-5555}
|
|
- MC_BLE_ADDRESS=${MC_BLE_ADDRESS:-}
|
|
- MC_BACKUP_ENABLED=${MC_BACKUP_ENABLED:-true}
|
|
- MC_BACKUP_HOUR=${MC_BACKUP_HOUR:-2}
|
|
- MC_BACKUP_RETENTION_DAYS=${MC_BACKUP_RETENTION_DAYS:-7}
|
|
- FLASK_HOST=${FLASK_HOST:-0.0.0.0}
|
|
- FLASK_PORT=${FLASK_PORT:-5000}
|
|
- FLASK_DEBUG=${FLASK_DEBUG:-false}
|
|
- MC_TRUST_PROXY=${MC_TRUST_PROXY:-false}
|
|
- TZ=${TZ:-UTC}
|
|
env_file:
|
|
- path: .env
|
|
required: false
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 3
|
|
start_period: 15s
|
|
|
|
# Optional HTTPS front end — Nginx Proxy Manager.
|
|
# Inert unless the "https" profile is active, so existing installs are untouched.
|
|
# Enable it by putting COMPOSE_PROFILES=https in .env, then run the usual
|
|
# `docker compose up -d --build` (or mcupdate). Full guide: docs/https-setup.md
|
|
#
|
|
# Both services share this project's default network, so the proxy reaches the
|
|
# app at http://mc-webui:5000 without the app publishing any port at all.
|
|
npm:
|
|
image: ${NPM_IMAGE:-jc21/nginx-proxy-manager:latest}
|
|
container_name: mc-webui-proxy
|
|
profiles: ["https"]
|
|
restart: unless-stopped
|
|
depends_on:
|
|
- mc-webui
|
|
ports:
|
|
- "${NPM_HTTP_PORT:-80}:80" # HTTP — also the Let's Encrypt HTTP-01 challenge
|
|
- "${NPM_HTTPS_PORT:-443}:443" # HTTPS
|
|
- "${NPM_ADMIN_PORT:-81}:81" # Proxy Manager admin UI
|
|
volumes:
|
|
- "${NPM_DATA_DIR:-./data/npm}:/data"
|
|
- "${NPM_LETSENCRYPT_DIR:-./data/letsencrypt}:/etc/letsencrypt"
|
|
environment:
|
|
- TZ=${TZ:-UTC}
|
|
- DISABLE_IPV6=${NPM_DISABLE_IPV6:-true}
|