Working example of traefikv2 setup with whoami and secure dashboard

Hi,

I currently have a traefik and whoami container running using docker-compose which works well.Hope so this will help someone.

Below is my docker-compose.yml and traefik.toml file

docker-compose.yml

version: "3.3"

services:
traefik:
image: "traefik:v2.4"
container_name: "traefik"
ports:
- "8082:8082"
- "443:443"
volumes:
- "./traefik.toml:/etc/traefik/traefik.toml"
- "./letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
labels:
# Enable the dashboard
- "traefik.enable=true"
# Domain for dashboard
- "traefik.http.routers.traefik.rule=Host(example.com)"
# Secure dashboard
- "traefik.http.routers.traefik.entrypoints=websecure"
# Using letsencrpt to generate ssl
- "traefik.http.routers.traefik.tls.certresolver=letsencrypt"
# Points to dashboard
- "traefik.http.routers.traefik.service=api@internal"
whoami:
# A container that exposes an API to show its IP address
image: traefik/whoami
restart: always
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(example.com) && PathPrefix(/whoami)"
- "traefik.http.routers.whoami.entrypoints=websecure"
- "traefik.http.routers.whoami.tls=true"

traefik.toml

[log]
level = "DEBUG"

[entryPoints]
[entryPoints.web]
address = ":8082"

[entryPoints.websecure]
address = ":443"

[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
permanent = "true"

[certificatesResolvers.letsencrypt.acme]
email = "myemail@gmail.com"
storage = "/letsencrypt/acme.json"
[certificatesResolvers.letsencrypt.acme.tlsChallenge]

[api]
dashboard = true

[providers.docker]
exposedByDefault = false

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.