This is the base configuration for Traefik, which requires complete environment variable configuration and supports both ACME and local certificates.
- ✅ Dynamic Service Integration: Automatic service discovery and configuration based on Docker labels
- ✅ Multiple Certificate Configurations: Support for both ACME automatic certificate issuance and local certificates
- ✅ HTTP/3 Support: Enable HTTP/3 (QUIC) protocol support
- ✅ Dashboard Interface: Built-in Traefik Dashboard visualization interface
- ✅ HTTPS Redirect: Automatically redirect HTTP requests to HTTPS
- ✅ GZIP Compression: Automatically enable response content compression
- ✅ Health Checks: Built-in health check mechanism
- ✅ Production Ready: Anonymous data collection and version checking disabled, suitable for production environments
Before using this configuration, you need to configure the following environment variables in base/.env:
# Service configuration
SERVICE_NAME=traefik
DOCKER_IMAGE=ghcr.io/traefik/traefik:v3.6.8
SERVICE_HTTP_PORT=80
SERVICE_HTTPS_PORT=443
SERVICE_DOMAIN=traefik.example.com- Docker 20.10+
- Docker Compose 2.0+
- Traefik Docker network created (run
../../scripts/prepare-network.sh)
docker compose -f traefik/base/docker-compose.yml up -dAfter successful startup, access the Traefik Dashboard:
- HTTPS:
https://traefik.example.com/dashboard/ - API:
https://traefik.example.com/api/
Note: Please replace
traefik.example.comwith your actual configured domain name and ensure DNS resolution is correct.
This configuration includes the following main features:
-
Port Configuration:
- HTTP port (default 80): For HTTP requests, automatically redirects to HTTPS
- HTTPS port (default 443): Supports both TCP and UDP (for HTTP/3)
-
Certificate Configuration:
- Supports local certificates (requires
./config/certs.tomlconfiguration)
- Supports local certificates (requires
-
Middlewares:
gzip: GZIP compression middlewareredir-https: HTTP to HTTPS redirect middleware
-
Service Discovery:
- Automatic service discovery based on Docker labels
- By default, not all containers are exposed, need to explicitly enable
traefik.enable=true
If using local certificates, you need to configure certificate paths:
[tls.stores.default.defaultCertificate]
certFile = "/data/ssl/example.com.pem.crt"
keyFile = "/data/ssl/example.com.pem.key"
[[tls.certificates]]
certFile = "/data/ssl/example.com.pem.crt"
keyFile = "/data/ssl/example.com.pem.key"Configure TLS options, including supported TLS versions and cipher suites:
[tls.options.default]
minVersion = "VersionTLS12"
sniStrict = false
cipherSuites = [
"TLS_AES_128_GCM_SHA256",
"TLS_AES_256_GCM_SHA384",
# ... more cipher suites
]If using local certificates, you need to:
- Generate certificates (refer to
../../traefik-make-local-certs/) - Configure certificate paths in
./config/certs.toml - Start the service
docker logs -f traefikAfter modifying configuration files, Traefik will automatically reload (watch mode is enabled). If you modified Docker Compose configuration, you need to restart the service:
docker compose -f traefik/base/docker-compose.yml restart traefikConfigure DNS_LIST in environment variables, separated by commas:
DNS_LIST=*.example.com,*.test.com,example.com- Ensure both TCP and UDP ports (443) are open
- Check if the firewall allows UDP port 443
- Some network environments may not support QUIC protocol
Remove or comment out the following label:
# - "--api.dashboard=true"