-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCaddyfile.dev
More file actions
100 lines (90 loc) · 2.54 KB
/
Copy pathCaddyfile.dev
File metadata and controls
100 lines (90 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Feedboard Development Caddyfile
#
# Proxies Vite + MediaMTX through single HTTPS port
#
# Environment variables:
# MTX_HOST - host.docker.internal (default, MediaMTX on host network)
# VITE_HOST - vite (default)
# THUMBNAILER_HOST - thumbnailer (default)
# AUTH_HOST - authproxy (default)
:443, localhost {
tls internal
# Auth proxy (when available)
handle /auth/* {
reverse_proxy {$AUTH_HOST:authproxy}:8091
}
handle /api/* {
reverse_proxy {$AUTH_HOST:authproxy}:8091
}
# Vite source files (must be before HLS to avoid .ts confusion)
handle /src/* {
reverse_proxy {$VITE_HOST:vite}:5173
}
handle /@* {
reverse_proxy {$VITE_HOST:vite}:5173
}
handle /node_modules/* {
reverse_proxy {$VITE_HOST:vite}:5173
}
# MediaMTX API - requires auth
handle /v3/* {
forward_auth {$AUTH_HOST:authproxy}:8091 {
uri /auth/me
}
reverse_proxy {$MTX_HOST:mediamtx}:9997
}
# Thumbnailer WebSocket (requires login)
@thumbs_ws {
path /thumbs/ws
header Connection *Upgrade*
}
handle @thumbs_ws {
forward_auth {$AUTH_HOST:authproxy}:8091 {
uri /auth/me
}
uri strip_prefix /thumbs
reverse_proxy {$THUMBNAILER_HOST:thumbnailer}:8090
}
# Thumbnailer API (requires login)
handle_path /thumbs/* {
forward_auth {$AUTH_HOST:authproxy}:8091 {
uri /auth/me
}
reverse_proxy {$THUMBNAILER_HOST:thumbnailer}:8090
}
# MediaMTX WebRTC - WHIP/WHEP endpoints
# MediaMTX doesn't handle OPTIONS preflight (returns 405), so Caddy handles it
@webrtc path_regexp webrtc ^/.+/wh[ie]p(/.*)?$
handle @webrtc {
@options method OPTIONS
handle @options {
header Access-Control-Allow-Origin *
header Access-Control-Allow-Methods "GET, POST, PATCH, DELETE, OPTIONS"
header Access-Control-Allow-Headers "Content-Type, Authorization, If-Match"
header Access-Control-Expose-Headers "Location, Link, ETag"
header Access-Control-Max-Age "86400"
respond 204
}
reverse_proxy {$MTX_HOST:mediamtx}:8889
}
# MediaMTX HLS - auth via cookie, pass token to MediaMTX
@hls path_regexp hls ^/.+\.(m3u8|ts|mp4)$
handle @hls {
forward_auth {$AUTH_HOST:authproxy}:8091 {
uri /auth/token?{http.request.uri.query}
copy_headers X-Auth-Token
}
# Pass the token as Authorization header to MediaMTX
reverse_proxy {$MTX_HOST:mediamtx}:8888 {
header_up Authorization "Bearer {http.request.header.X-Auth-Token}"
}
}
# Static examples (bypass SPA routing)
handle /examples/* {
reverse_proxy {$VITE_HOST:vite}:5173
}
# Vite dev server (default) - handles SPA routes
handle {
reverse_proxy {$VITE_HOST:vite}:5173
}
}