Repository navigation
Expand file tree
/
Copy pathCaddyfile
More file actions
111 lines (100 loc) · 4.18 KB
/
Copy pathCaddyfile
File metadata and controls
111 lines (100 loc) · 4.18 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
# Caddy reverse proxy — automatic HTTPS for all three apps.
#
# CADDY_TLS=internal -> Caddy's built-in CA (self-signed), local tests
# CADDY_TLS=you@example.com -> automatic Let's Encrypt for real domains
#
# With CADDY_TLS=internal, never keep a copy of the root certificate. Caddy
# generates a new local CA whenever the caddy_data volume is recreated (down -v,
# a fresh setup, a wiped DATA_ROOT), and every generation carries the SAME subject
# name ("Caddy Local Authority - <year> ECC Root"), so a saved root goes stale
# without looking stale: curl fails with "unable to get local issuer certificate"
# while the keychain entry still shows the expected name. Read it out of the
# running container instead (see README "Local quick start"); verify.sh uses -k.
#
# This file is bind-mounted :ro, so `docker compose up -d` does NOT pick up edits.
# Apply them with `docker compose exec caddy caddy reload --config
# /etc/caddy/Caddyfile` or a force-recreate of the container.
#
# Domains come from the environment (SEAFILE_DOMAIN / IMMICH_DOMAIN /
# VAULTWARDEN_DOMAIN / NAVIDROME_DOMAIN), so this file never changes between
# deployments.
#
# Public certs are issued over the HTTP challenge, which needs inbound :80. For a
# DNS challenge instead (wildcard certs, or no inbound :80), build a Caddy image
# with your provider's DNS module and replace `tls {$CADDY_TLS}` below with a
# `tls { dns <provider> ... }` block.
#
# No trusted_proxies: as the edge, Caddy ignores any client-sent X-Forwarded-For
# and forwards the real peer, so a forged XFF can't poison Immich's / Vaultwarden's
# per-IP login limiters — no header_up override needed.
{
# Admin API on loopback only (the healthcheck hits it).
admin localhost:2019
# Static Caddyfile — don't autosave the loaded JSON config to /config, the only
# write that volume would otherwise take.
persist_config off
}
# Shared response headers. No prefix = replace, so upstreams can't leave duplicates.
(security_headers) {
header {
# No preload — it's a hard-to-undo browser commitment; opt in (and raise
# max-age to >=1y) only if submitting to hstspreload.org.
Strict-Transport-Security "max-age=15552000; includeSubDomains"
X-Content-Type-Options "nosniff"
# same-origin (stricter than the browser default): drops the Referer
# cross-site so Seafile/Immich share-link tokens in the URL never leak,
# but keeps it same-origin for Seahub's Django CSRF check.
Referrer-Policy "same-origin"
# Two halves of the same banner: Caddy sets Server on its own responses and
# Via on proxied ones (2.10+). Neither carries a version, so dropping them
# hides the product name only. The :80 -> :443 redirects are synthesized by
# automatic HTTPS, outside these site blocks, and still answer Server: Caddy.
-Server
-Via
}
}
# ------------------------------------------------------------------- Immich --
{$IMMICH_DOMAIN} {
tls {$CADDY_TLS}
import security_headers
# Large uploads — don't cap the request body.
reverse_proxy immich-server:2283
}
# ------------------------------------------------------------------ Seafile --
{$SEAFILE_DOMAIN} {
tls {$CADDY_TLS}
import security_headers
# Real-time notification sidecar, sharing this domain with Seahub. It serves
# its routes at the root (websocket on /, plus /events and /ping), so
# handle_path strips the prefix this mount adds.
handle_path /notification* {
reverse_proxy notification-server:8083
}
handle {
# Large uploads — don't cap the request body.
reverse_proxy seafile-server:80 {
# Lets Seahub (Django) emit https URLs and pass CSRF checks.
header_up X-Forwarded-Proto https
}
}
}
# -------------------------------------------------------------- Vaultwarden --
{$VAULTWARDEN_DOMAIN} {
tls {$CADDY_TLS}
import security_headers
reverse_proxy vaultwarden:8080
}
# ---------------------------------------------------------------- Navidrome --
{$NAVIDROME_DOMAIN} {
tls {$CADDY_TLS}
import security_headers
# navidrome-upload, on Navidrome's origin so its page can use the web UI's
# login (see navidrome-upload's README). It keeps the /upload prefix.
redir /upload /upload/
handle /upload/* {
reverse_proxy navidrome-upload:8080
}
handle {
reverse_proxy navidrome:4533
}
}