Traefik is a modern, cloud-native reverse proxy and load balancer that automatically discovers services and configures routing. It integrates natively with Docker, Kubernetes, and other orchestrators. This guide installs Traefik on Ubuntu 24.04 LTS with Docker.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.04 LTS server
  • Docker Engine and Docker Compose installed
  • A domain name pointed to the server
  • A user in the docker group

Step 1 – Create the Traefik Configuration Directory

Set up the directory structure:

mkdir -p ~/traefik
touch ~/traefik/acme.json
chmod 600 ~/traefik/acme.json

Step 2 – Create the Traefik Static Configuration

Create ~/traefik/traefik.yml:

api:
  dashboard: true

entryPoints:
  web:
    address: ":80"
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https
  websecure:
    address: ":443"

certificatesResolvers:
  myresolver:
    acme:
      email: [email protected]
      storage: /acme.json
      httpChallenge:
        entryPoint: web

providers:
  docker:
    exposedByDefault: false

Step 3 – Create a Docker Network

Create a shared Traefik network:

docker network create traefik-net

Step 4 – Create docker-compose.yml

Create ~/traefik/docker-compose.yml:

version: '3.9'
services:
  traefik:
    image: traefik:v3.0
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./traefik.yml:/traefik.yml:ro
      - ./acme.json:/acme.json
    networks:
      - traefik-net

networks:
  traefik-net:
    external: true

Step 5 – Start Traefik

Launch Traefik:

cd ~/traefik && docker compose up -d

Step 6 – Deploy a Service Behind Traefik

Add Traefik labels to any container:

services:
  whoami:
    image: traefik/whoami
    networks:
      - traefik-net
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.example.com`)"
      - "traefik.http.routers.whoami.tls=true"
      - "traefik.http.routers.whoami.tls.certresolver=myresolver"

Step 7 – Access the Dashboard

Visit http://your_server_ip:8080 to see the Traefik dashboard with all configured routers, services, and middleware.

Conclusion

Traefik is now running on Ubuntu 24.04 LTS as a cloud-native reverse proxy. It automatically requests and renews Let’s Encrypt certificates and discovers Docker containers via labels — no manual Nginx config needed.