Put TLS in front of the stack
The base compose stack publishes plain HTTP on the web container (port
${WEB_PORT:-8080}). To serve Tradr over HTTPS you have two supported paths: add
one of the two shipped compose overrides — Caddy or Traefik — in front of web,
or front the stack with a reverse proxy you already run. Both overrides obtain and
renew a certificate automatically, redirect HTTP to HTTPS, and close the base
plaintext port so only HTTPS is reachable.
Prerequisites
Section titled “Prerequisites”- A domain with a DNS record that points at this host. Both overrides request a certificate for it over port 80, so the name must already resolve to your server.
- Ports 80 and 443 open to the host. The certificate authority reaches port 80 for the HTTP challenge, and clients reach port 443 for HTTPS.
- Docker Compose v2.24.4 or newer. The overrides drop
web’s own published port with the!resetYAML merge tag; that tag, and the multi-file merge fixes it relies on, shipped in Compose v2.24.4. Check your version withdocker compose version. The merge reference describes what!resetdoes.
Step 1 — Prepare your .env
Section titled “Step 1 — Prepare your .env”If you have not run the stack yet, generate the required secrets without starting it:
./docker/quickstart.sh --env-onlyThis writes .env with a fresh POSTGRES_PASSWORD and ENCRYPTION_KEY. An
existing .env is never overwritten.
Then set the TLS variables in .env:
TRADR_DOMAIN— the domain the proxy serves and requests a certificate for (for exampletradr.example.com). Both overrides require it.ACME_EMAIL— a contact address the certificate authority needs. The Traefik override requires it; Caddy does not.COMPOSE_FILE— set it so a plaindocker compose up -dloads the override without passing both-ffiles each time. Pick one override, not both.
Step 2 — Add an override
Section titled “Step 2 — Add an override”Caddy needs only TRADR_DOMAIN. In .env:
TRADR_DOMAIN=tradr.example.comCOMPOSE_FILE=docker-compose.yml:docker-compose.caddy.ymlStart the stack:
docker compose up -dIf you did not set COMPOSE_FILE, pass both files instead:
docker compose -f docker-compose.yml -f docker-compose.caddy.yml up -dCaddy obtains and renews the certificate itself, redirects HTTP to HTTPS, and
forwards to the internal web service on port 80. Certificate state lives in a
named volume, so a restart or an image upgrade does not request a new
certificate.
Traefik
Section titled “Traefik”Traefik needs TRADR_DOMAIN and ACME_EMAIL. In .env:
TRADR_DOMAIN=tradr.example.comACME_EMAIL=you@example.comCOMPOSE_FILE=docker-compose.yml:docker-compose.traefik.ymlStart the stack:
docker compose up -dIf you did not set COMPOSE_FILE, pass both files instead:
docker compose -f docker-compose.yml -f docker-compose.traefik.yml up -dTraefik obtains and renews the certificate through its ACME resolver, redirects
HTTP to HTTPS, and routes TRADR_DOMAIN to the internal web service through the
shipped file provider (docker/traefik/dynamic.yml). No Docker socket is mounted.
Certificate state lives in a named volume.
Step 3 — Check the result
Section titled “Step 3 — Check the result”From any host that can resolve the domain:
curl -I https://tradr.example.comA response over HTTP/2 — a 200, or the SPA’s own redirect — confirms TLS is
live. curl -I http://tradr.example.com should return a redirect to the HTTPS
URL.
Either override closes web’s base plaintext port (${WEB_PORT:-8080}): the
override resets web.ports, so only the proxy’s 80 and 443 are bound and the
plain-HTTP path is no longer reachable.
Set WEB_BASE_URL when email is on
Section titled “Set WEB_BASE_URL when email is on”If you have configured transactional email (the SMTP_HOST, EMAIL_FROM and
WEB_BASE_URL trio), set WEB_BASE_URL to the HTTPS origin:
WEB_BASE_URL=https://tradr.example.comThe links in password-reset and verification emails are built from
WEB_BASE_URL, so it must point at the HTTPS origin, not the old plain-HTTP port.
Rate limiting and TRUSTED_PROXIES
Section titled “Rate limiting and TRUSTED_PROXIES”The api keys its per-IP rate limit on the real client address. It reads that
address from the X-Forwarded-For header only when the immediate sender is a
trusted proxy. TRUSTED_PROXIES in .env lists those senders; it defaults to
172.28.0.0/24, the compose network’s subnet.
- A shipped override needs no change. The Caddy or Traefik service runs on the
tradrnetwork, so its address falls inside${TRADR_SUBNET:-172.28.0.0/24}— already the defaultTRUSTED_PROXIES. The api therefore trusts the proxy and keys the limit on the forwarded client address. - If you change
TRADR_SUBNET, setTRUSTED_PROXIESto the same range. Otherwise the proxy’s address no longer matches, the api stops trusting it, and every request is attributed to the proxy. - An edge outside the
tradrnetwork — your own host proxy, or Cloudflare — has no address in that subnet. Add that edge’s address, or Cloudflare’s published IP ranges, toTRUSTED_PROXIESas a comma-separated list.
If you already run an edge
Section titled “If you already run an edge”If you already terminate TLS with your own reverse proxy or with Cloudflare, do
not add an override. Keep the base stack, which publishes web on
${WEB_PORT:-8080}, point your edge at that port, and terminate HTTPS there. Add
the edge’s address to TRUSTED_PROXIES, as described above, so per-IP rate
limiting stays accurate.
When a certificate fails
Section titled “When a certificate fails”If HTTPS does not come up, the proxy logs the certificate error. Read it with:
docker compose logs caddyor, for Traefik:
docker compose logs traefikThe usual causes are a DNS record that does not yet point at this host, or port 80 closed so the certificate authority cannot reach the HTTP challenge. Fix the prerequisite, then restart the stack.
Next steps
Section titled “Next steps”- Self-host with Docker Compose — the base setup this page builds on.
- Environment variable reference — every key and its default.