-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCaddyfile
More file actions
132 lines (117 loc) · 3.58 KB
/
Copy pathCaddyfile
File metadata and controls
132 lines (117 loc) · 3.58 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Railpack serves static Vite output with Caddy. A root Caddyfile replaces the default
# (see https://railpack.com/languages/node#static-sites ). These routes mirror
# vite.config.ts `LLM_PROXIES` so POST /api/llm/{provider}/... works in production.
# POST /api/proxy mirrors vite.config.ts `corsProxyGate` (web_fetch / web_search when
# no TinyFish key, youtube_transcribe, etc.): reverse_proxy to a small sidecar —
# `node scripts/cors-proxy-server.mjs` (default http://127.0.0.1:8799). Railpack/Dokploy:
# Do not set `scripts.start` in package.json: Railpack treats that as a custom start command,
# disables SPA/Caddy deploy (spa.go hasCustomStartCommand), and the image no longer includes Caddy.
# Use railpack.json `deploy.startCommand` + `deploy.aptPackages` (see repo railpack.json) instead.
# Override bind with WEBAGENT_CORS_PROXY_HOST / WEBAGENT_CORS_PROXY_PORT.
# Globals stay compatible with Debian apt Caddy (~2.6): no persist_config / servers trusted_proxies.
{
admin off
auto_https off
log {
format json
}
}
:{$PORT:80} {
log {
format json
}
respond /health 200
header {
X-Content-Type-Options "nosniff"
-Server
}
@shell path /index.html /sw.js /sw-register.js /version.json
header @shell Cache-Control "no-cache, no-store, must-revalidate"
# OpenCode Zen (Big Pickle free): /api/llm/opencode/* -> https://opencode.ai/zen/v1/*
handle /api/llm/opencode* {
uri replace /api/llm/opencode /zen/v1
reverse_proxy https://opencode.ai:443 {
flush_interval -1
header_up Host opencode.ai
}
}
# OpenRouter: /api/llm/openrouter/* -> https://openrouter.ai/api/v1/*
handle /api/llm/openrouter* {
uri replace /api/llm/openrouter /api/v1
reverse_proxy https://openrouter.ai:443 {
flush_interval -1
header_up Host openrouter.ai
}
}
# Ollama cloud: /api/llm/ollama/* -> https://ollama.com/v1/*
handle /api/llm/ollama* {
uri replace /api/llm/ollama /v1
reverse_proxy https://ollama.com:443 {
flush_interval -1
header_up Host ollama.com
}
}
# JSON CORS proxy (same contract as Vite corsProxyGate); path is exactly /api/proxy.
handle /api/proxy {
reverse_proxy http://{$WEBAGENT_CORS_PROXY_HOST:127.0.0.1}:{$WEBAGENT_CORS_PROXY_PORT:8799} {
flush_interval -1
}
}
# Edge TTS synthesis + voice list (same contract as Vite edgeTtsGate).
handle /api/edge-tts* {
reverse_proxy http://{$WEBAGENT_CORS_PROXY_HOST:127.0.0.1}:{$WEBAGENT_CORS_PROXY_PORT:8799} {
flush_interval -1
}
}
# Subscription OAuth (Nous, OpenAI Codex) — same contract as Vite llmProxyGate.
handle /api/providers/oauth* {
reverse_proxy http://{$WEBAGENT_CORS_PROXY_HOST:127.0.0.1}:{$WEBAGENT_CORS_PROXY_PORT:8799} {
flush_interval -1
}
}
# Subscription LLM proxy (Nous passthrough, Codex Responses adapter).
handle /api/llm/nous* {
reverse_proxy http://{$WEBAGENT_CORS_PROXY_HOST:127.0.0.1}:{$WEBAGENT_CORS_PROXY_PORT:8799} {
flush_interval -1
}
}
handle /api/llm/openai-codex* {
reverse_proxy http://{$WEBAGENT_CORS_PROXY_HOST:127.0.0.1}:{$WEBAGENT_CORS_PROXY_PORT:8799} {
flush_interval -1
}
}
# WASM / ONNX: skip gzip/zstd — compressed binaries break ORT/sql.js in the browser.
@wasm {
path_regexp wasm \.wasm$
}
@onnx {
path_regexp onnx \.onnx$
}
handle @wasm {
root * dist
file_server {
hide .git
hide .env*
}
}
handle @onnx {
root * dist
file_server {
hide .git
hide .env*
}
}
# Static SPA (Vite default outDir: dist; override with RAILPACK_SPA_OUTPUT_DIR if needed)
handle {
root * dist
file_server {
hide .git
hide .env*
}
encode {
gzip
zstd
}
try_files {path} {path}.html {path}/index.html /index.html
}
}