hello everyone,
i am trying to install traefik via docker compose on docker swarm, but i am experiencing the following problems:
-
enabling dashboard login and putting api.insecure=false the dashboard doesn't show up.
-
by enabling dashboard login and leaving api.insecure=true the dashboard remains reachable without authentication.
-
by setting the labels in the docker compose balanced services, the routing does not work and I do not see them as routers in the dashboard
-
by enabling tls and putting the self-signed wildcard certificate in the configuration file, it always tells me "404 page not found" and in the logs I see the error "uknown certificate"
I leave you below the contents of my files, can you tell me how to configure it so that I have the following aspects?
- reach the dashboard via traefik.company.local
- have authentication on the dashboard.
- balance the docker compose services using the correct labels and self-signed certificate.
thank you very much
traefik.yml:
global:
checkNewVersion: true
sendAnonymousUsage: false # true by default
# (Optional) Log information
# ---
log:
# Log level
#
# Optional
# Default: "ERROR"
#
level: DEBUG
# Sets the filepath for the traefik log. If not specified, stdout will be used.
# Intermediate directories are created if necessary.
#
# Optional
# Default: os.Stdout
#
filePath: /var/log/traefik/traefik.log
# (Optional) Accesslog
# ---
accesslog:
format: common # common, json, logfmt
filePath: /var/log/traefik/access.log
# (Optional) Enable API and Dashboard
# ---
api:
dashboard: true # true by default
insecure: true # Don't do this in production!
# Entry Points configuration
# ---
entryPoints:
web:
address: :80
# (Optional) Redirect to HTTPS
# ---
#http:
# redirections:
# entryPoint:
# to: websecure
# scheme: https
websecure:
address: :443
# Configure your CertificateResolver here...
# ---
# certificatesResolvers:
# staging:
# acme:
# email: your-email@example.com
# storage: /etc/traefik/certs/acme.json
# caServer: "https://acme-staging-v02.api.letsencrypt.org/directory"
# httpChallenge:
# entryPoint: web
#
# production:
# acme:
# email: your-email@example.com
# storage: /etc/traefik/certs/acme.json
# caServer: "https://acme-v02.api.letsencrypt.org/directory"
# httpChallenge:
# entryPoint: web
# (Optional) Overwrite Default Certificates
tls:
stores:
default:
defaultCertificate:
certFile: /etc/traefik/certs/cert.pem
keyFile: /etc/traefik/certs/cert-key.pem
# (Optional) Disable TLS version 1.0 and 1.1
options:
default:
minVersion: VersionTLS12
providers:
docker:
swarmMode: true
exposedByDefault: true
file:
#filename: /etc/traefik/middlewares.yml
# watch for dynamic configuration changes
directory: /etc/traefik
watch: true
dynamicConfiguration:
middlewares:
# Include il file middlewares.yml
- file:
filename: /etc/traefik/middlewares.yml
docker-compose.yml:
version: '3.8'
services:
traefik:
image: traefik:v2.10
container_name: Traefik
restart: unless-stopped
command:
- "--providers.docker.network=Traefik"
ports:
- 80:80
- 443:443
- 8080:8080
deploy:
placement:
constraints:
- "node.labels.tipo == produzione"
volumes:
- /data/docker/appdata/traefik:/etc/traefik
- /var/run/docker.sock:/var/run/docker.sock:ro
- /data/docker/logs/traefik:/var/log/traefik
labels:
- "traefik.enable=true"
# HTTP-to-HTTPS Redirect
#- "traefik.http.routers.http-catchall.entrypoints=http"
#- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
#- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
#- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
# HTTP Routers
#- "traefik.http.routers.traefik.entrypoints=web"
- "traefik.http.routers.traefik.rule=Host(`traefik.company.local`)"
#- "traefik.http.services.traefik.loadbalancer.server.port=8080"
#- "traefik.http.routers.traefik.tls=true" # Some people had 404s without this
#- "traefik.http.routers.traefik.tls.domains[0].main=company.local"
#- "traefik.http.routers.traefik.tls.domains[0].sans=*.company.local"
#- "traefik.http.routers.traefik.middlewares=middlewares-basic-auth@file"
#- "traefik.http.services.traefik-rtr.loadbalancer.server.port=8080"
## Services - API
#- "traefik.http.routers.traefik-rtr.service=api@internal"
## Middlewares
#- "traefik.http.routers.traefik-rtr.middlewares=chain-basic-auth@file"
networks:
- Traefik
networks:
Traefik:
external: true
middlewares.yml:
http:
middlewares:
test-auth:
basicAuth:
users:
- "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"
- "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"