CloudLinux.ro
Docker & containers

How to use Traefik as a reverse proxy for containers

Updated 7/20/2026

Traefik is a reverse proxy built for containers: it discovers services automatically and gets them HTTPS certificates with no manual configuration. Perfect when you run multiple apps on one server.

1. The Traefik service in Compose

services:
  traefik:
    image: traefik:v3.0
    command:
      - "--providers.docker=true"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "[email protected]"
      - "--certificatesresolvers.le.acme.storage=/acme.json"
      - "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./acme.json:/acme.json

2. Label the app

Add labels to your service so Traefik knows where to send traffic:

  app:
    image: my-app
    labels:
      - "traefik.http.routers.app.rule=Host(`example.com`)"
      - "traefik.http.routers.app.tls.certresolver=le"

3. Start

docker compose up -d

Traefik detects the app, exposes it on the given domain and automatically obtains an HTTPS certificate. For the Nginx version, see Nginx as a reverse proxy.

Put this guide into practice on your own VPS

EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.

See pricing

Related tutorials