Skip to main content
Traefik is configured with labels on the container rather than a separate config file, which makes it a natural fit if you already run it in front of your other containers. If you do not, Caddy is less work for the same result. If you are not sure what a reverse proxy is or why she needs one, Domain and HTTPS explains it first.

Which port, and why

Both numbers are right, for different routes to the same place.

Set it up

1

Add Traefik to your Docker Compose file

Because Traefik reaches her over the Docker network, the ports: mapping on the PostQueen service is no longer needed and is worth removing. Leaving it in place publishes her on host port 4007 as well, which bypasses your proxy and your HTTPS.
2

Tell PostQueen her address

Routing alone is not enough. She also has to know the address people use, because sign-in origins and every social network’s return address are built from it. In the same docker-compose.yaml, on the postqueen service:
Keep the /api suffix, and leave no trailing slashes.
Apply it with docker compose down && docker compose up -d.
3

Check it

HTTP/2 200 means the router and PostQueen are both working.
This block does not get you a real certificate. tls=true turns TLS on, but with no certificate resolver configured Traefik serves its own self-signed default, so browsers warn and curl needs -k. Add a resolver, usually ACME against Let’s Encrypt, and name it on the router with traefik.http.routers.postqueen.tls.certresolver. Traefik’s own ACME documentation has the entrypoint and storage settings that go with it.Caddy does this part for you, which is why it is the shorter path.
A 404 from Traefik instead is usually a missing traefik.enable=true label, since the service above runs with exposedbydefault=false.

Next steps

Caddy

The shorter path, with certificates handled for you.

Nginx

The right choice when you already run Nginx for other things.

WebSockets and dev tunnels

Path routing for split deployments, and HMR behind a tunnel.

Self-host gotchas

What tends to break once she is behind a proxy.