Minimal Traefik v2 setup for localhost with HTTPS. TLS is enabled by default for all routers on the websecure entrypoint, so services do not need traefik.http.routers.<name>.tls=true.
.
├── config/
│ ├── static.yml # Traefik static config (entrypoints, providers, API)
│ └── dynamic.yml # TLS certs, dashboard router
├── certs/ # Create this; put mkcert output here
├── docker-compose.yml
├── whoami.yml # Example service
└── README.md
-
Clone and go to the project root
cd traefik-v2-https-ssl-localhost -
Install mkcert and generate certificates (first time only)
mkcert -install mkdir -p certs mkcert -cert-file certs/local-cert.pem -key-file certs/local-key.pem \ "docker.localhost" "*.docker.localhost" "domain.local" "*.domain.local"
On macOS, mkcert may prompt for your password (Keychain + system trust).
-
Create the Docker network
docker network create web
-
Start Traefik
docker-compose up -d
-
Start the whoami example (optional)
docker-compose -f whoami.yml up -d
- Whoami: https://whoami.docker.localhost
- Traefik dashboard: https://traefik.docker.localhost
HTTP (port 80) redirects to HTTPS (port 443).