A service over HTTPS: Traefik and the first service
Bring up Traefik as its own stack and expose memos through it by name with a Let’s Encrypt certificate. The why is in the manuals, linked from every stage.
Start froma server after level 2, “Protection”: key-only login, ufw lets in SSH, 80 and 443, Docker installed with capped logs.
What you get
internet ── 80, 443 ──▶ Traefik ─┬─▶ whoami.example.org test service: shows what arrived └─▶ memos.example.org notes; data in /opt/memos/data/opt/traefik/ the proxy stack: compose, traefik.yml, acme.json/opt/whoami/ the test service/opt/memos/ the first real service
You’ll needA domain: A records for whoami.example.org and memos.example.org pointing at the server, 203.0.113.10, without the Cloudflare proxy (grey cloud)
You’ll needAn email for the Let’s Encrypt account: [email protected]
Your values
Filled into the commands and files of this and other recipes on the path; stored in this browser only. Highlighted parts come from “Your values”.
Not like this — see “If it doesn’t work”, stage cases.
If it doesn’t work
Stage 1
dig +short prints nothing
Cause
There’s no A record yet, or DNS hasn’t caught up: a new record shows up within minutes, a changed one after the old record’s TTL.
Fix
Check the record at the registrar and wait; don’t go on — without DNS Let’s Encrypt won’t issue a certificate.
Stage 1
ss shows nginx or apache on :80 or :443
Cause
The ports are taken, and the Traefik container won’t start: Bind for 0.0.0.0:80 failed: port is already allocated.
Fix
sudo systemctl disable --now nginx (or apache2), then run ss again.
Stage 2
The log says is a directory about acme.json
Cause
The file didn’t exist on the first start, so Docker created a directory in its place (A missing volume path).
Fix
sudo docker compose down, sudo rmdir data/acme.json, then touch and chmod 600 from stage 2 again, sudo docker compose up -d.
Stage 2
The log says permissions 644 for /acme.json are too open, please use 600
Cause
The file was created with default permissions.
Fix
sudo chmod 600 /opt/traefik/data/acme.json and sudo docker compose restart traefik.
Stage 3
curl to a new name prints nothing, and curl -v complains about the certificate: TRAEFIK DEFAULT CERT
Cause
Traefik is still getting the certificate: the first request to a new name waits 10–30 s for it.
Fix
Try again in half a minute. Longer than that — sudo docker logs traefik 2>&1 | grep -i acme and the stage 4 case.
Stage 3
404 page not found on whoami or memos
Cause
traefik.enable=true is missing, the name in Host has a typo, or the container isn’t running.
Fix
sudo docker ps --filter name=memos, and compare the labels with the stage 3 file.
Stage 3
Gateway Timeout after about 30 seconds
Cause
The container isn’t on the proxy network: its compose file has no networks block.
Fix
Add the network as in the stage 3 files and run sudo docker compose up -d.
Stage 4
No certificate gets issued, and the log shows an acme error with connection or timeout
Cause
Let’s Encrypt couldn’t reach port 80: the provider’s firewall or a rule on the server blocks it.
Fix
Open http://whoami.example.org from a phone on mobile data — it should redirect. If port 80 can’t be opened, use the DNS challenge (Traefik and Let’s Encrypt).
Stage 4
The log says too many failed authorizations recently
Cause
Five failed validations per name per hour — after that Let’s Encrypt refuses until the hour is up.
Fix
Find the cause with the case above and wait an hour. While experimenting, use the staging server: caServer: https://acme-staging-v02.api.letsencrypt.org/directory in traefik.yml (Traefik from scratch).