-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathCaddyfile.dokploy
More file actions
56 lines (53 loc) · 2.29 KB
/
Caddyfile.dokploy
File metadata and controls
56 lines (53 loc) · 2.29 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
# Caddyfile.dokploy
#
# Same routing as the original Caddyfile but with TLS stripped —
# Dokploy's Traefik terminates HTTPS on the edge and forwards plain
# HTTP to this Caddy on the internal dokploy-network. Caddy keeps
# doing what it's good at here: path-based routing, static file
# serving with Cache-Control headers, and the SPA try_files
# fallback. No `auto_https` because we're listening on :80 only.
{
auto_https off
}
:80 {
# All API routes flow through one shared reverse_proxy block so
# the retry policy below applies uniformly. The retry policy is
# the "zero-downtime poor man's edition": when the upstream API
# container is restarting (compose recreate on deploy), Caddy
# holds the request and retries every 500 ms for up to 30 s
# instead of returning a 502 immediately. From the user's side a
# deploy just feels like a brief lag instead of a flash of
# broken-page errors.
#
# lb_try_duration 30s — total time we'll keep retrying the
# single upstream while it's down.
# Bigger than the ~10–30 s window the
# knowledge-api takes to come up.
# lb_try_interval 500ms — gap between retries.
#
# This uses Caddy's load-balancing primitive on a single upstream
# (a degenerate "balancer" of size 1); the lb_* directives gate
# request-side retry without needing multiple replicas.
@api path /indices /indices/* /api/* /auth/* /mcp /encode /health /events /stats/*
handle @api {
reverse_proxy knowledge-api:8080 {
lb_try_duration 30s
lb_try_interval 500ms
}
}
# Static frontend files with the same cache-control layering as
# the production Caddyfile — versioned assets get a long
# stale-while-revalidate cache, images get a long browser
# cache, HTML stays no-cache so deploys propagate.
handle {
root * /web
@static_assets path *.css *.js *.woff *.woff2 *.ttf *.otf
header @static_assets Cache-Control "public, max-age=3600, stale-while-revalidate=86400"
@static_images path *.png *.jpg *.jpeg *.gif *.webp *.svg *.ico
header @static_images Cache-Control "public, max-age=86400, stale-while-revalidate=604800"
@static_html path_regexp ^/?$|^/[A-Za-z0-9_-]+/?$|^/.+\.html$
header @static_html Cache-Control "no-cache"
try_files {path} {path}.html /index.html
file_server
}
}