HTTPS and proxies
Serve Knotworking on a domain with automatic certificates, keep the API private, or sit behind your own reverse proxy.
On a domain
Point a domain at the server and tell Caddy about it. Caddy gets and renews a Let's Encrypt certificate by itself. The HTTPS setup adds a second Compose file, compose.https.yaml, which publishes port 443.
DOMAIN=knot.example.com
APP_URL=https://knot.example.com
HTTP_PORT=80
COMPOSE_FILE=compose.yaml:compose.https.yaml
docker compose --env-file deploy/.env up -d
Open ports 80 and 443 in the firewall. Caddy needs port 80 to issue certificates and to redirect to HTTPS.
COMPOSE_FILE makes every later command (up, logs, exec, updates) use both files. Never run up with only compose.yaml on an HTTPS installation, or Caddy loses port 443. Calendar sync needs HTTPS on a real domain.
On a local network
On a local network, plain HTTP is fine. Leave DOMAIN and COMPOSE_FILE unset and only the HTTP port is published, so a machine that already uses port 443 works as it is.
Keeping the API private
Only Caddy should be reachable from outside. The API holds every permission check and sign-in, and its port (4000) should never face a network.
- Standalone (running from source): the API binds to
127.0.0.1by default, so only the web app on the same machine can reach it. - Bundled Compose stack: the
apiservice setsAPI_HOST=0.0.0.0so the web app and MCP server can reach it asapi:4000, but only on the private Compose network. The compose file publishes no port forapi,web,mcpordb; only Caddy hasports:. - Set
API_HOSTyourself only when your proxy runs on another machine and has to reach the API over a private network. Then firewall the API port so that only the proxy can connect: the proxy supplies the client address used for sign-in rate limits, so anything else that reaches the API could forge it.
Behind another proxy
Caddy records each visitor's address in X-Forwarded-For, which sign-in rate limits rely on. If you put another proxy or load balancer in front of Caddy:
- Have it overwrite
X-Forwarded-For, or raiseTRUSTED_PROXIESon thewebservice to the number of proxies. - Turn off buffering and compression for
/api/v1/workspaces/*/events, so live updates arrive at once (in nginx,proxy_buffering off;). - Allow request bodies at least as large as
UPLOAD_MAX_BYTESplus about 64 KB. - Forward
/mcpwith itsHostheader and body untouched.
If people report being locked out at random, check this first. When the client address can't be worked out, everyone shares one rate-limit bucket, so a few failed sign-ins lock everyone out for a short time.
Security headers
The bundled Caddyfile sends X-Content-Type-Options, X-Frame-Options and Referrer-Policy, removes the Server header, and adds Strict-Transport-Security on HTTPS connections only. There is deliberately no Content-Security-Policy; add one in your own proxy only after testing every page, the document editor included.