Files
web-alterflixhub/docker/traefik-dynamic.example.yml
T
Bkk1234 3ebfcfea75 docs(traefik): match production config (priority 200, real container, shared middleware)
Record the values verified on the server: container
alterflixhub-compose-doefaz-web-1:30004 on dokploy-network, redirect-to-https
from middlewares.yml, and priority 200 to win over the Dokploy docker-provider
routers whose label still hardcodes server.port=8080 (the 502 cause).
2026-11-22 23:52:54 +07:00

51 lines
2.6 KiB
YAML

# Traefik dynamic config (File Provider) สำหรับ alterflixhub.hobbypj.com
# วางที่ /etc/dokploy/traefik/dynamic/alterflixhub-hobbypj.yml
# - Dokploy UI: Web Server → Traefik File System → dynamic/ → New File
# - หรือ SSH: scp แล้ว `docker cp <file> dokploy_dokploy-traefik.1.<hash>:/etc/dokploy/traefik/dynamic/`
# Traefik watch โฟลเดอร์นี้อยู่แล้ว → save แล้วมีผลทันที ไม่ต้อง restart
#
# ค่าที่ใช้จริงบน server
# container : alterflixhub-compose-doefaz-web-1 (image alterflixhub-web:latest, nginx, PORT=30004)
# network : dokploy-network (Traefik เป็น swarm service อยู่บน network นี้)
# middleware : redirect-to-https (ประกาศใน middlewares.yml ของเครื่องนั้นอยู่แล้ว)
#
# ทำไมต้องมี priority: 200
# Dokploy สร้าง router จาก docker labels ให้โดเมนเดียวกันด้วย โดย label
# traefik.http.services.<name>.loadbalancer.server.port ถูก hardcode เป็น 8080
# แต่ nginx ฟัง 30004 → router ชุดนั้นตอบ 502 และ rule ยาวเท่ากัน (Host เดียวกัน)
# Traefik จึงเลือกไม่แน่นอน → ต้องประกาศ priority ให้ router ในไฟล์นี้ชนะ
http:
routers:
# 1) http (พอร์ต 80) → redirect ไป https (middleware กลางของเครื่อง)
alterflixhub-hobbypj-http-router:
rule: Host(`alterflixhub.hobbypj.com`)
service: alterflixhub-service
entryPoints:
- web
priority: 200
middlewares:
- redirect-to-https
# 2) https (พอร์ต 443) → เสิร์ฟเว็บจริง + ขอ cert จาก letsencrypt
alterflixhub-hobbypj-https-router:
rule: Host(`alterflixhub.hobbypj.com`)
service: alterflixhub-service
entryPoints:
- websecure
priority: 200
tls:
certResolver: letsencrypt
services:
alterflixhub-service:
loadBalancer:
# ชื่อ container : พอร์ต *ใน* คอนเทนเนอร์ (ไม่ใช่พอร์ตที่ map ออก host)
servers:
- url: http://alterflixhub-compose-doefaz-web-1:30004
passHostHeader: true
healthCheck:
path: /healthz
interval: 30s
timeout: 3s