The VPS this site runs on (a Hostinger box) was not empty. It already had a Traefik container — traefik-traefik-1, vanilla traefik:latest on the host network, docker provider enabled, with a letsencrypt certificate resolver configured inside it. That container owns ports 80 and 443.

Which leaves two options for anything else I want to serve:

  1. Run my own proxy from deploy/docker-compose.yml, which means fighting the existing Traefik for 80/443. That was never going to work without stopping the thing already using those ports.
  2. Leave the running proxy alone and attach to it.

I went with option 2. deploy/docker-compose.attach.yml is that choice written down: no traefik service at all, just site, status (Uptime Kuma) and dash (Heimdall) joining a shared bridge network called appnet and opting in through labels. The cert resolver and ACME email stay inside the running proxy — I don’t touch them, and I don’t need to.

What “attach” actually means in labels

services:
  site:
    networks: [appnet]
    expose: ["80"]
    labels:
      - "traefik.enable=true"
      - "traefik.docker.network=appnet"
      - "traefik.http.routers.site.rule=Host(`hetsulab.tech`)"
      - "traefik.http.routers.site.entrypoints=websecure"
      - "traefik.http.routers.site.tls=true"
      - "traefik.http.routers.site.tls.certresolver=letsencrypt"
      - "traefik.http.services.site.loadbalancer.server.port=80"

Three things in there matter more than they look:

  • traefik.enable=true. The stack is written for a proxy configured with exposedByDefault=false — containers have to opt in with a label, joining a network alone gets them nowhere. deploy/docker-compose.yml L24 shows that setting in the own-Traefik variant; the flags on the running traefik-traefik-1 aren’t readable from here, so I’m not claiming what they are. The labels below are what make the routing explicit either way — you opt in per container, not per network.
  • traefik.docker.network=appnet. Traefik is on the host network and the site is on a bridge; without pinning the network, Traefik can pick the wrong IP to dial. This one line is the difference between “routes” and “502”.
  • loadbalancer.server.port=80. nginx listens on 80 inside the container. The label is how the proxy learns that, since expose alone isn’t enough.

Deploy is one command, the same one as always:

cd deploy
docker compose -f docker-compose.attach.yml up -d --build

Traefik picks the new containers up from the docker socket and builds routers. No edits to the running proxy, no second proxy, no port conflict.

The misleading part: 404 page not found

DNS already pointed hetsulab.tech at the VPS before any of this. So the first check after deploying hit an HTTPS endpoint and got:

$ curl -s https://hetsulab.tech/
404 page not found

and, in parallel:

$ echo | openssl s_client -connect hetsulab.tech:443 -servername hetsulab.tech 2>/dev/null \
    | openssl x509 -noout -subject
subject=CN=TRAEFIK DEFAULT CERT

My first instinct was DNS. It was wrong, and here is the reasoning I should have done first: a DNS failure doesn’t give you an HTTP status code. Those two lines together say the opposite of “broken DNS” —

  • 404 page not found is Traefik’s own body, lowercase and terse. Something accepted the TCP connection, terminated TLS, and answered as an HTTP server.
  • CN=TRAEFIK DEFAULT CERT is the proxy’s self-signed fallback, served when it has a TLS router but hasn’t obtained a certificate for the hostname yet.

So: proxy up, TLS terminating, DNS fine, no router matching Host(hetsulab.tech). Traefik answered because it was the only thing listening. This is inference from the two observations above, but it’s the inference the evidence supports and it matched what happened next — once the labels were on the containers and the containers were actually recreated, the router existed, ACME issued a real certificate, and the 404 became a 200.

The detail worth keeping: labels are read from the running container, so adding them to a compose file does nothing until the container is recreated. A docker compose up -d that decides nothing changed will happily leave you staring at the same 404.

Checking that it’s real now

$ curl -sI https://hetsulab.tech/notes/ | head -2
HTTP/2 200

$ echo | openssl s_client -connect hetsulab.tech:443 -servername hetsulab.tech 2>/dev/null \
    | openssl x509 -noout -subject -issuer -dates
subject=CN=hetsulab.tech
issuer=C=US, O=Let's Encrypt, CN=YR1
notBefore=Nov 20 17:12:48 2026 GMT
notAfter=Feb 18 17:12:47 2027 GMT

The certificate names the host and comes from Let’s Encrypt, and the issued/expiry window lines up with when the stack went up — so the ACME HTTP-01 challenge went through the running proxy, not mine.

DNS, for the record

The apex resolves to the VPS:

$ getent hosts hetsulab.tech www.hetsulab.tech
2a02:4780:5e:c80::1 hetsulab.tech
2a02:4780:5e:c80::1 hetsulab.tech www.hetsulab.tech

That’s the AAAA record for this box. The runbook lists its IPv4 as 189.31.32.122. The subdomains are a separate, unfinished chore: as I write this, getent hosts status.hetsulab.tech returns nothing, because the A/AAAA records for status, dash, lab, vpn and dl haven’t been added in Hostinger’s DNS zone editor yet. Containers being up and healthy does not make a hostname resolve — those are two independent failures with the same curl: (6) Could not resolve host smell.

What I’d do the same next time

  • Look at the shape of the error before the words in it. A proxy’s own 404 body plus a default certificate is a routing gap, and it’s a much better signal than the page title suggests.
  • One proxy per machine. Reuse it by labels; don’t install a second copy of the thing that already owns the ports.
  • Pin the docker network in the labels. It’s a one-line fix for the “why is this 502” hour.
  • Treat DNS records as deploy steps, not documentation. They’re the part that silently isn’t done.