Files
360_player/docker-compose.yml
T
JianMiauandClaude Opus 5 ae3221c460 移除 app 容器的對外埠,對外只保留 nginx 的 HTTPS 入口
摘要:
360-player 服務改為只 expose 不 ports,明文 HTTP 不再離開容器內網,
對外入口只剩 360-player-web 的 8443。

根本原因:
先前為了讓區網能用 IP 免憑證警告直連,保留了 app 的 ${PORT}:8360 對外映射。
但該埠在路由器上也有對外轉發,實際使用時是以網域連線
(http://jianmiau.tk:8360),等於在外網留了一條明文路徑。

影響:
外網走 8360 時,影片內容與 API 全程未加密,加上 TLS 的意義被抵消。

修法:
- docker-compose.yml 拿掉 360-player 的 ports,只留 expose: 8360;
  nginx 仍可經容器內網以服務名連到它
- 保留註解說明如何加回來,並註明要綁死區網介面而非 0.0.0.0
- .env / .env.example 移除不再被 compose 參照的 PORT
- README 的 SSL 段落改寫,說明代價是區網也要用網域連

驗證:
docker compose config 展開後只有一個 published port(8443 → 8443),
360-player 服務底下僅剩 expose。

備註:路由器上 8360 的 port forwarding 需另外手動關閉,僅改 compose 不足以關掉外網入口。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 15:01:56 +08:00

53 lines
1.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
services:
360-player:
container_name: 360-player
build:
context: .
dockerfile: Dockerfile
image: 360-player:latest
restart: unless-stopped
# 不對外開埠:只透過容器內網讓 nginx 連得到,外面一律走 HTTPS。
# 若要在區網用 IP 直連明文(會省掉憑證警告),自行加回:
# ports:
# - "127.0.0.1:${PORT:-8360}:8360" # 或綁區網 IP
expose:
- "8360"
volumes:
# 影片資料夾(NAS 上的實際路徑)→ 容器內 /videos,唯讀
- "${VIDEO_DIR:-/volume1/photo/Badminton}:/videos:ro"
# 轉檔輸出 + probe 快取 → 容器內 /cache(需要可寫)
- "${CACHE_DIR:-./cache}:/cache"
environment:
TZ: ${TZ:-Asia/Taipei}
# CPU 轉檔時 libx264 的 presetNAS CPU 弱可改 superfast / ultrafast(檔案會稍大)
X264_PRESET: ${X264_PRESET:-veryfast}
# 本機為 Intel J4025UHD 600),已啟用 VAAPI 硬體轉檔;
# 換到沒有 /dev/dri 的機器時要把下面兩行註解掉,否則容器起不來。
devices:
- /dev/dri:/dev/dri
360-player-web:
container_name: 360-player-web
build:
context: .
dockerfile: docker/nginx/Dockerfile
image: 360-player-web:latest
restart: unless-stopped
depends_on:
- 360-player
ports:
- "${HTTPS_PORT:-8443}:8443"
environment:
TZ: ${TZ:-Asia/Taipei}
NGINX_PORT: 8443
NGINX_SERVER_NAME: ${NGINX_SERVER_NAME:-_}
SSL_CERT_DIR: /etc/nginx/certs
SSL_CERT_FILE_NAME: ${SSL_CERT_FILE_NAME:-cert.pem}
SSL_CHAIN_FILE_NAME: ${SSL_CHAIN_FILE_NAME:-chain.pem}
SSL_KEY_FILE_NAME: ${SSL_KEY_FILE_NAME:-privkey.pem}
UPSTREAM_HOST: 360-player
UPSTREAM_PORT: 8360
volumes:
# 憑證來源與 badminton-scoreboard 共用;DSM 續期後 entrypoint 會自動 reload
- "${SSL_CERT_DIR:-/volume1/docker/certs}:/etc/nginx/certs:ro"