Files
wekan/snap-src/Caddyfile
T
Lauri Ojansivu 37d2397603 Caddyfile examples are Caddy 2, and the snap's Caddy proxies to where WeKan listens.
The snap runs Caddy 2, and migrate-caddyfile-v1-to-v2.sh treats a Caddyfile
that `caddy adapt` rejects as Caddy v1: it moves it to Caddyfile.v1.bak-<n>
and, when it cannot convert it, writes the default in its place - on every
start. 19 Caddyfile examples in the docs were Caddy v1 (`proxy / localhost:3001
{ websocket transparent }`, `browse`, `fastcgi`, `tls self_signed`, `ext`,
v1 `log`/`errors`, `root /path`), so a file copied from the snap install page
was renamed each time it was put back. All are now Caddy 2 (reverse_proxy,
file_server browse, php_fastcgi, tls internal, try_files, log output) and pass
`caddy adapt` with Caddy 2.11.7. Also:

- `http://X https://X { tls ... }` became `X {`: Caddy 2 refuses TLS on the
  http address and redirects to https by itself;
- the Windows examples `load` the certs folder - Caddy 2's load takes folders;
- the Docker Meteor3 Caddyfile gave the Let's Encrypt and CloudFlare variants
  of one site the same host, which Caddy 2 refuses as ambiguous; each has its
  own host now;
- Caddy.md's logs example and its systemd unit, installer and setcap are
  Caddy 2 (`caddy run --config`, no getcaddy.com, no -conf/-agree/-email).

The fallback template the migration writes proxied to localhost:3000. With
Caddy enabled the snap runs WeKan on caddy-bind-port (default 3001), so a
migrated site pointed at nothing. Both templates now read the snap settings
from caddy-control's environment - `:{$CADDY_PORT:8080}` and `reverse_proxy
localhost:{$CADDY_BIND_PORT:3001}` - so `snap set wekan port=...` reaches
Caddy on the restart the configure hook already does; that hook's sed lines
only ever matched Caddy v1 lines. The commented TLS example in the template
had `protocols h1` inside a site and a stray `}`, so uncommenting it failed;
it uses `alpn http/1.1` now.

tests/caddyfileExamplesV2.test.cjs finds every Caddyfile in the docs and the
snap, fails on Caddy v1 syntax and on a Caddy 1 command line, checks the
templates' ports, and with a Caddy 2 binary runs `caddy adapt` on all 30.
snapStagePackages.test.cjs pinned the wrong port 3000 and now pins 3001.

Thanks to Group-Deed and xet7 !
2026-10-15 22:05:49 +03:00

33 lines
963 B
Caddyfile

# Caddy 2 configuration for Wekan
#
# {$CADDY_PORT} is the snap's `port` setting and {$CADDY_BIND_PORT} its
# `caddy-bind-port`, the port WeKan listens on when Caddy is enabled
# (bin/wekan-read-settings). `sudo snap set wekan port=...` then reaches
# this file by itself, without anything editing it.
:{$CADDY_PORT:8080} {
# Reverse proxy to Wekan
reverse_proxy localhost:{$CADDY_BIND_PORT:3001} {
# Enable WebSocket support
header_up Connection {>Connection}
header_up Upgrade {>Upgrade}
}
}
# SSL/TLS example with HTTP/2 disabled for Firefox WebSocket compatibility
# Uncomment and customize for your domain
#{$DOMAIN:wekan.example.com} {
# # Enable TLS but use HTTP/1.1 protocol
# tls {
# protocols tls1.2 tls1.3
# alpn http/1.1
# }
#
# # Reverse proxy to Wekan
# reverse_proxy localhost:{$CADDY_BIND_PORT:3001} {
# # Enable WebSocket support
# header_up Connection {>Connection}
# header_up Upgrade {>Upgrade}
# }
#}