Web (Gateway)

Gateway เสิร์ฟ Control UI บนเบราว์เซอร์ ขนาดเล็ก (Vite + Lit) จากพอร์ตเดียวกับ Gateway WebSocket:

  • ค่าเริ่มต้น: http://<host>:18789/
  • คำนำหน้าตัวเลือก: ตั้งค่า gateway.controlUi.basePath (เช่น /mayros)

ความสามารถอยู่ใน Control UI หน้านี้มุ่งเน้นไปที่โหมดการผูก ความปลอดภัย และพื้นผิวที่หันหน้าเว็บ

Webhooks

เมื่อ hooks.enabled=true Gateway ยังเปิดเผย endpoint webhook ขนาดเล็กบนเซิร์ฟเวอร์ HTTP เดียวกัน ดู การตั้งค่า Gatewayhooks สำหรับการพิสูจน์ตัวตน + เพย์โหลด

การตั้งค่า (เปิดตามค่าเริ่มต้น)

Control UI เปิดใช้งานตามค่าเริ่มต้น เมื่อมี assets (dist/control-ui) คุณสามารถควบคุมมันผ่านการตั้งค่า:

json5
{
  gateway: {
    controlUi: { enabled: true, basePath: "/mayros" }, // basePath ตัวเลือก
  },
}

การเข้าถึง Tailscale

Integrated Serve (แนะนำ)

เก็บ Gateway ไว้ที่ loopback และให้ Tailscale Serve พร็อกซีมัน:

json5
{
  gateway: {
    bind: "loopback",
    tailscale: { mode: "serve" },
  },
}

จากนั้นเริ่ม gateway:

bash
mayros gateway

เปิด:

  • https://<magicdns>/ (หรือ gateway.controlUi.basePath ที่คุณกำหนดค่า)

การผูก Tailnet + โทเค็น

json5
{
  gateway: {
    bind: "tailnet",
    controlUi: { enabled: true },
    auth: { mode: "token", token: "your-token" },
  },
}

จากนั้นเริ่ม gateway (ต้องใช้โทเค็นสำหรับการผูกที่ไม่ใช่ loopback):

bash
mayros gateway

เปิด:

  • http://<tailscale-ip>:18789/ (หรือ gateway.controlUi.basePath ที่คุณกำหนดค่า)

อินเทอร์เน็ตสาธารณะ (Funnel)

json5
{
  gateway: {
    bind: "loopback",
    tailscale: { mode: "funnel" },
    auth: { mode: "password" }, // หรือ MAYROS_GATEWAY_PASSWORD
  },
}

หมายเหตุความปลอดภัย

  • การพิสูจน์ตัวตน Gateway ต้องการตามค่าเริ่มต้น (โทเค็น/รหัสผ่านหรือ Tailscale identity headers)
  • การผูกที่ไม่ใช่ loopback ยัง ต้องการ โทเค็น/รหัสผ่านที่แชร์ (gateway.auth หรือ env)
  • วิซาร์ดสร้างโทเค็น gateway ตามค่าเริ่มต้น (แม้ใน loopback)
  • UI ส่ง connect.params.auth.token หรือ connect.params.auth.password
  • Control UI ส่งส่วนหัว anti-clickjacking และยอมรับเฉพาะ การเชื่อมต่อ websocket ของเบราว์เซอร์ same-origin เว้นแต่ตั้งค่า gateway.controlUi.allowedOrigins
  • ด้วย Serve, Tailscale identity headers สามารถตอบสนองการพิสูจน์ตัวตน Control UI/WebSocket เมื่อ gateway.auth.allowTailscale เป็น true (ไม่ต้องการโทเค็น/รหัสผ่าน) จุดสิ้นสุด HTTP API ยังคงต้องการโทเค็น/รหัสผ่าน
  • gateway.tailscale.mode: "funnel" ต้องการ gateway.auth.mode: "password" (รหัสผ่านที่แชร์)

การสร้าง UI

Gateway เสิร์ฟไฟล์แบบคงที่จาก dist/control-ui สร้างพวกเขาด้วย:

bash
pnpm ui:build # ติดตั้ง UI deps อัตโนมัติในการรันครั้งแรก